]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix required enum's name in migration
authorAnn Kamyshnikova <akamyshnikova@mirantis.com>
Wed, 23 Oct 2013 11:58:35 +0000 (15:58 +0400)
committerAnn Kamyshnikova <akamyshnikova@mirantis.com>
Wed, 23 Oct 2013 12:34:00 +0000 (16:34 +0400)
Enums must contain name parameter for PostgreSQL and need to be
deleted after dropping table.

Closes-Bug: #1243652
Closes-Bug: #1243213

Change-Id: I01d18ff25572bbe9e6a8b8c6ae27f250ab154734

neutron/db/migration/alembic_migrations/versions/c88b6b5fea3_cisco_n1kv_tables.py

index e924c1a919a3aca2eb63ec2778b1ee7bf94389a5..293d051c4b07e5fa2b8c775a659ab1823b98526f 100644 (file)
@@ -36,6 +36,9 @@ import sqlalchemy as sa
 
 from neutron.db import migration
 
+vlan_type = sa.Enum('vlan', 'vxlan', name='vlan_type')
+network_type = sa.Enum('network', 'policy', name='network_type')
+
 
 def upgrade(active_plugins=None, options=None):
     if not migration.should_run(active_plugins, migration_for_plugins):
@@ -74,7 +77,7 @@ def upgrade(active_plugins=None, options=None):
         'cisco_network_profiles',
         sa.Column('id', sa.String(length=36), nullable=False),
         sa.Column('name', sa.String(length=255), nullable=True),
-        sa.Column('segment_type', sa.Enum('vlan', 'vxlan'), nullable=False),
+        sa.Column('segment_type', vlan_type, nullable=False),
         sa.Column('segment_range', sa.String(length=255), nullable=True),
         sa.Column('multicast_ip_index', sa.Integer(), autoincrement=False,
                   nullable=True),
@@ -84,7 +87,7 @@ def upgrade(active_plugins=None, options=None):
     )
     op.create_table(
         'cisco_n1kv_profile_bindings',
-        sa.Column('profile_type', sa.Enum('network', 'policy'), nullable=True),
+        sa.Column('profile_type', network_type, nullable=True),
         sa.Column('tenant_id', sa.String(length=36), nullable=False),
         sa.Column('profile_id', sa.String(length=36), nullable=False),
         sa.PrimaryKeyConstraint('tenant_id', 'profile_id')
@@ -133,7 +136,9 @@ def downgrade(active_plugins=None, options=None):
     op.drop_table('cisco_n1kv_vlan_allocations')
     op.drop_table('cisco_n1kv_port_bindings')
     op.drop_table('cisco_n1kv_profile_bindings')
+    network_type.drop(op.get_bind(), checkfirst=False)
     op.drop_table('cisco_network_profiles')
+    vlan_type.drop(op.get_bind(), checkfirst=False)
     op.drop_table('cisco_n1kv_vxlan_allocations')
     op.drop_table('cisco_n1kv_vmnetworks')
     op.drop_table('cisco_policy_profiles')