From: Ann Kamyshnikova Date: Tue, 9 Jun 2015 08:30:06 +0000 (+0300) Subject: Fix Enum usage in 589f9237ca0e_cisco_n1kv_ml2_driver_tables X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1552f311532fdbd03a79ecfc1fae488b072c5a14;p=openstack-build%2Fneutron-build.git Fix Enum usage in 589f9237ca0e_cisco_n1kv_ml2_driver_tables PostgreSQL is more sensitive with types than MySQL, it creates a separate type when a Enum is created. In migration 589f9237ca0e type profile_type is trying to be created, but the type with such name was already created in havana_initial migration. The solution for this is not to create type in 589f9237ca0e migration when dialect is PostgreSQL and use already created. Closes-bug: #1463301 Change-Id: I66e74d50cc70673de8635616076779cc20cde113 --- diff --git a/neutron/db/migration/alembic_migrations/versions/589f9237ca0e_cisco_n1kv_ml2_driver_tables.py b/neutron/db/migration/alembic_migrations/versions/589f9237ca0e_cisco_n1kv_ml2_driver_tables.py index 6c091ce5d..c1f4422bd 100644 --- a/neutron/db/migration/alembic_migrations/versions/589f9237ca0e_cisco_n1kv_ml2_driver_tables.py +++ b/neutron/db/migration/alembic_migrations/versions/589f9237ca0e_cisco_n1kv_ml2_driver_tables.py @@ -31,7 +31,6 @@ import sqlalchemy as sa network_profile_type = sa.Enum('vlan', 'vxlan', name='network_profile_type') -profile_type = sa.Enum('network', 'policy', name='profile_type') def upgrade(): @@ -103,7 +102,15 @@ def upgrade(): ondelete='CASCADE'), sa.PrimaryKeyConstraint('physical_network', 'vlan_id') ) - + # Bugfix for 1463301: PostgreSQL creates type when Enum assigned to column, + # but type profile_type was already created in cisco_init_opts, so it needs + # to be reused. MySQL do not create type for Enums. + if op.get_context().dialect.name == 'postgresql': + profile_type = sa.dialects.postgresql.ENUM('network', 'policy', + name='profile_type', + create_type=False) + else: + profile_type = sa.Enum('network', 'policy', name='profile_type') op.create_table( 'cisco_ml2_n1kv_profile_bindings', sa.Column('profile_type', profile_type, nullable=True),