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: Ideafb3a2a92868a5e8b86390a27bf930ae617d0d
This commit is contained in:
Rodolfo Alonso Hernandez 2024-11-08 22:10:09 +00:00 committed by Rodolfo Alonso
parent 0835712429
commit 6361423018
2 changed files with 7 additions and 23 deletions

View File

@ -20,9 +20,9 @@ Create Date: 2015-04-15 04:19:57.324584
"""
import sqlalchemy as sa
from alembic import op
from neutron.db import migration
import sqlalchemy as sa
# revision identifiers, used by Alembic.
@ -37,11 +37,5 @@ new_action = sa.Enum('allow', 'deny', 'reject', name='firewallrules_action')
def upgrade():
# NOTE: postgresql have a builtin ENUM type, so just altering the
# column won't works
# https://bitbucket.org/zzzeek/alembic/issues/270/altering-enum-type
# alter_enum that was already invented for such case in neutron
# https://github.com/openstack/neutron/blob/master/neutron/db/migration/__init__.py
migration.alter_enum(
'firewall_rules', 'action', enum_type=new_action, nullable=True)
op.alter_column('firewall_rules', 'action', type_=new_action,
nullable=True)

View File

@ -30,7 +30,9 @@ EXTERNAL_TABLES.update({'firewall_router_associations'})
VERSION_TABLE = 'alembic_version_fwaas'
class _TestModelsMigrationsFWaaS(test_migrations._TestModelsMigrations):
class TestModelsMigrationsFWaaS(test_migrations.TestModelsMigrations,
testlib_api.MySQLTestCaseMixin,
testlib_api.SqlTestCaseLight):
def db_sync(self, engine):
cfg.CONF.set_override(
@ -55,18 +57,6 @@ class _TestModelsMigrationsFWaaS(test_migrations._TestModelsMigrations):
return True
class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin,
_TestModelsMigrationsFWaaS,
testlib_api.SqlTestCaseLight):
pass
class TestModelsMigrationsPostgresql(testlib_api.PostgreSQLTestCaseMixin,
_TestModelsMigrationsFWaaS,
testlib_api.SqlTestCaseLight):
pass
class TestSanityCheck(testlib_api.SqlTestCaseLight):
BUILD_SCHEMA = False