From: jun xie Date: Wed, 19 Mar 2014 10:01:52 +0000 (+0800) Subject: Use different name for the same constraint X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5d6cb0c62e0245735a9d511d2f871776055ff224;p=openstack-build%2Fneutron-build.git Use different name for the same constraint 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 --- diff --git a/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py b/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py index fa8d99d1f..f3b444a22 100644 --- a/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py +++ b/neutron/db/migration/alembic_migrations/versions/2447ad0e9585_add_ipv6_mode_props.py @@ -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') diff --git a/neutron/db/models_v2.py b/neutron/db/models_v2.py index 2c77ec67e..99e18f5c9 100644 --- a/neutron/db/models_v2.py +++ b/neutron/db/models_v2.py @@ -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):