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 <ts-takahashi@nec.com>
This commit is contained in:
parent
f1a0c7ebc0
commit
d744c3936e
@ -28,6 +28,7 @@ down_revision = 'abbef484b34c'
|
|||||||
|
|
||||||
from alembic import op # noqa: E402
|
from alembic import op # noqa: E402
|
||||||
import sqlalchemy as sa # noqa: E402
|
import sqlalchemy as sa # noqa: E402
|
||||||
|
from sqlalchemy.engine import reflection # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
def _migrate_duplicate_vnf_package_vnfd_id(table):
|
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):
|
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',
|
op.alter_column('vnf_package_vnfd',
|
||||||
'deleted',
|
'deleted',
|
||||||
type_=sa.String(36), default="0")
|
type_=sa.String(36), default="0")
|
||||||
|
Loading…
Reference in New Issue
Block a user