mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
Silence error on migration 4736ec66ce19 constraint drop (#5729)
* Silence error on migration 4736ec66ce19 constraint drop * typo + lint
This commit is contained in:
parent
6cc52c614c
commit
f0beb3ab80
@ -7,13 +7,10 @@ Create Date: 2017-10-03 14:37:01.376578
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
import logging
|
||||||
revision = '4736ec66ce19'
|
|
||||||
down_revision = 'f959a6652acd'
|
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy.exc import OperationalError
|
|
||||||
|
|
||||||
from superset.utils import (
|
from superset.utils import (
|
||||||
generic_find_fk_constraint_name,
|
generic_find_fk_constraint_name,
|
||||||
@ -21,6 +18,9 @@ from superset.utils import (
|
|||||||
generic_find_uq_constraint_name,
|
generic_find_uq_constraint_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '4736ec66ce19'
|
||||||
|
down_revision = 'f959a6652acd'
|
||||||
|
|
||||||
conv = {
|
conv = {
|
||||||
'fk': 'fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s',
|
'fk': 'fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s',
|
||||||
@ -101,16 +101,24 @@ def upgrade():
|
|||||||
|
|
||||||
batch_op.drop_column('datasource_name')
|
batch_op.drop_column('datasource_name')
|
||||||
|
|
||||||
# Drop the old more restrictive uniqueness constraint.
|
try:
|
||||||
with op.batch_alter_table('datasources', naming_convention=conv) as batch_op:
|
# Drop the old more restrictive uniqueness constraint.
|
||||||
batch_op.drop_constraint(
|
with op.batch_alter_table('datasources', naming_convention=conv) as batch_op:
|
||||||
generic_find_uq_constraint_name(
|
batch_op.drop_constraint(
|
||||||
'datasources',
|
generic_find_uq_constraint_name(
|
||||||
{'datasource_name'},
|
'datasources',
|
||||||
insp,
|
{'datasource_name'},
|
||||||
) or 'uq_datasources_datasource_name',
|
insp,
|
||||||
type_='unique',
|
) or 'uq_datasources_datasource_name',
|
||||||
)
|
type_='unique',
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning(
|
||||||
|
'Constraint drop failed, you may want to do this '
|
||||||
|
'manually on your database. For context, this is a known '
|
||||||
|
'issue around undeterministic contraint names on Postgres '
|
||||||
|
'and perhaps more databases through SQLAlchemy.')
|
||||||
|
logging.exception(e)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
Loading…
Reference in New Issue
Block a user