]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use different name for the same constraint
authorjun xie <junxiebj@cn.ibm.com>
Wed, 19 Mar 2014 10:01:52 +0000 (18:01 +0800)
committerjun xie <junxiebj@cn.ibm.com>
Thu, 20 Mar 2014 02:26:37 +0000 (10:26 +0800)
In DB2, a constraint-name must not identify a constraint
that was already specified within the same CREATE TABLE
statement. The current CREATE TABLE statement uses the same
constraint name 'ipv6_modes' for both ipv6_ra_mode and
ipv6_address_mode column. This change tries to use different
names.

Change-Id: Id4d82fb7e0e570a843e28856e531e25578a4351a
Closes-Bug: #1294568

neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py
neutron/db/models_v2.py

index fa8d99d1f8b9b4bf0baed35fd1af7caf54fbd90e..f3b444a22e5a2897ef4797eb44b18c6eac24e883 100644 (file)
@@ -47,14 +47,16 @@ def upgrade(active_plugins=None, options=None):
     # https://bitbucket.org/zzzeek/alembic/issue/89
     context = op.get_context()
     if context.bind.dialect.name == 'postgresql':
-        op.execute("CREATE TYPE ipv6_modes AS ENUM ('%s', '%s', '%s')"
+        op.execute("CREATE TYPE ipv6_ra_modes AS ENUM ('%s', '%s', '%s')"
+                   % ('slaac', 'dhcpv6-stateful', 'dhcpv6-stateless'))
+        op.execute("CREATE TYPE ipv6_address_modes AS ENUM ('%s', '%s', '%s')"
                    % ('slaac', 'dhcpv6-stateful', 'dhcpv6-stateless'))
     op.add_column('subnets',
                   sa.Column('ipv6_ra_mode',
                             sa.Enum('slaac',
                                     'dhcpv6-stateful',
                                     'dhcpv6-stateless',
-                                    name='ipv6_modes'),
+                                    name='ipv6_ra_modes'),
                             nullable=True)
                   )
     op.add_column('subnets',
@@ -62,7 +64,7 @@ def upgrade(active_plugins=None, options=None):
                             sa.Enum('slaac',
                                     'dhcpv6-stateful',
                                     'dhcpv6-stateless',
-                                    name='ipv6_modes'),
+                                    name='ipv6_address_modes'),
                             nullable=True)
                   )
 
@@ -75,4 +77,5 @@ def downgrade(active_plugins=None, options=None):
     op.drop_column('subnets', 'ipv6_address_mode')
     context = op.get_context()
     if context.bind.dialect.name == 'postgresql':
-        op.execute('DROP TYPE ipv6_modes')
+        op.execute('DROP TYPE ipv6_ra_modes')
+        op.execute('DROP TYPE ipv6_address_modes')
index 2c77ec67e1a8e705b328adecfdd5adaa62c7650f..99e18f5c97741589abd2478da4a5235453ccd89b 100644 (file)
@@ -187,11 +187,11 @@ class Subnet(model_base.BASEV2, HasId, HasTenant):
     ipv6_ra_mode = sa.Column(sa.Enum(constants.IPV6_SLAAC,
                                      constants.DHCPV6_STATEFUL,
                                      constants.DHCPV6_STATELESS,
-                                     name='ipv6_modes'), nullable=True)
+                                     name='ipv6_ra_modes'), nullable=True)
     ipv6_address_mode = sa.Column(sa.Enum(constants.IPV6_SLAAC,
                                   constants.DHCPV6_STATEFUL,
                                   constants.DHCPV6_STATELESS,
-                                  name='ipv6_modes'), nullable=True)
+                                  name='ipv6_address_modes'), nullable=True)
 
 
 class Network(model_base.BASEV2, HasId, HasTenant):