commit aee1a048cba463f1fd8eae8b122dc31c58f80055 Author: Toshiaki Takahashi Date: Thu Jul 9 14:59:17 2020 +0900 Fix: Remove wrong constraint in vnf_package_vnfd Currently, vnf_package_vnfd table has a following constraint in database created by tacker db migration. This is incorrect, so this patch remove the constraint. CONSTRAINT `CONSTRAINT_1` CHECK (`deleted` in (0,1)) This is created because `deleted` was boolean before. `deleted` is varchar(36) now, so db migration change its type by alter_column method. But this does not remove check constraint. This patch add drop_constraint to remove the constraint. Change-Id: I7a62ecf3eeec2f363d0f099bb46d3dec7948501a Closes-Bug: #1886622 Signed-off-by: Toshiaki Takahashi (cherry picked from commit d744c3936ef6afa4b985e2241be3555b63fb699f) diff --git a/tacker/db/migration/alembic_migrations/versions/975e28392888_add_unique_key_vnf_package_vnfd.py b/tacker/db/migration/alembic_migrations/versions/975e28392888_add_unique_key_vnf_package_vnfd.py index 9841c53..9bdb584 100644 --- a/tacker/db/migration/alembic_migrations/versions/975e28392888_add_unique_key_vnf_package_vnfd.py +++ b/tacker/db/migration/alembic_migrations/versions/975e28392888_add_unique_key_vnf_package_vnfd.py @@ -28,6 +28,7 @@ down_revision = 'abbef484b34c' from alembic import op # noqa: E402 import sqlalchemy as sa # noqa: E402 +from sqlalchemy.engine import reflection # noqa: E402 def _migrate_duplicate_vnf_package_vnfd_id(table): @@ -56,6 +57,17 @@ def _migrate_duplicate_vnf_package_vnfd_id(table): def upgrade(active_plugins=None, options=None): + check_constraints = (reflection.Inspector.from_engine(op.get_bind()) + .get_check_constraints('vnf_package_vnfd')) + for constraint in check_constraints: + if '`deleted`' in constraint['sqltext']: + op.drop_constraint( + constraint_name=constraint['name'], + table_name='vnf_package_vnfd', + type_="check" + ) + break + op.alter_column('vnf_package_vnfd', 'deleted', type_=sa.String(36), default="0")