Use `alembic.op.alter_column`

The Neutron method ``alter_enum`` has been removed in [1]. Use
``alembic.op.alter_column`` instead. This migration won't be
compatible with PostgreSQL.

This patch is also removing the functional tests using PostgreSQL.

[1]https://review.opendev.org/c/openstack/neutron/+/934171

Change-Id: I50be52a463ba5c40e43139d82a3327d9c5488694
This commit is contained in:
Rodolfo Alonso Hernandez 2024-11-08 22:04:40 +00:00 committed by Rodolfo Alonso
parent 6372f73e4c
commit 960cf21df8
3 changed files with 13 additions and 22 deletions

View File

@ -21,7 +21,7 @@ Create Date: 2016-04-08 22:33:53.286083
""" """
from neutron.db import migration from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -33,7 +33,7 @@ new_auth = sa.Enum('sha1', 'sha256', name='vpn_auth_algorithms')
def upgrade(): def upgrade():
migration.alter_enum('ikepolicies', 'auth_algorithm', new_auth, op.alter_column('ikepolicies', 'auth_algorithm', type_=new_auth,
nullable=False, do_drop=False) nullable=False, do_drop=False)
migration.alter_enum('ipsecpolicies', 'auth_algorithm', new_auth, op.alter_column('ipsecpolicies', 'auth_algorithm', type_=new_auth,
nullable=False, do_rename=False, do_create=False) nullable=False, do_rename=False, do_create=False)

View File

@ -21,6 +21,7 @@ Create Date: 2016-11-04 18:00:49.219140
""" """
from alembic import op
from neutron.db import migration from neutron.db import migration
import sqlalchemy as sa import sqlalchemy as sa
@ -37,7 +38,7 @@ new_auth = sa.Enum('sha1', 'sha256', 'sha384', 'sha512',
def upgrade(): def upgrade():
migration.alter_enum('ikepolicies', 'auth_algorithm', new_auth, op.alter_column('ikepolicies', 'auth_algorithm', type_=new_auth,
nullable=False, do_drop=False) nullable=False, do_drop=False)
migration.alter_enum('ipsecpolicies', 'auth_algorithm', new_auth, op.alter_column('ipsecpolicies', 'auth_algorithm', type_=new_auth,
nullable=False, do_rename=False, do_create=False) nullable=False, do_rename=False, do_create=False)

View File

@ -25,7 +25,9 @@ EXTERNAL_TABLES = set(external.TABLES) - set(external.VPNAAS_TABLES)
VERSION_TABLE = 'alembic_version_vpnaas' VERSION_TABLE = 'alembic_version_vpnaas'
class _TestModelsMigrationsVPNAAS(test_migrations._TestModelsMigrations): class TestModelsMigrationsVPNAAS(test_migrations.TestModelsMigrations,
testlib_api.MySQLTestCaseMixin,
testlib_api.SqlTestCaseLight):
def db_sync(self, engine): def db_sync(self, engine):
cfg.CONF.set_override( cfg.CONF.set_override(
@ -48,15 +50,3 @@ class _TestModelsMigrationsVPNAAS(test_migrations._TestModelsMigrations):
if type_ == 'index' and reflected and name.startswith("idx_autoinc_"): if type_ == 'index' and reflected and name.startswith("idx_autoinc_"):
return False return False
return True return True
class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin,
_TestModelsMigrationsVPNAAS,
testlib_api.SqlTestCaseLight):
pass
class TestModelsMigrationsPostgresql(testlib_api.PostgreSQLTestCaseMixin,
_TestModelsMigrationsVPNAAS,
testlib_api.SqlTestCaseLight):
pass