[migrations] Fixing issue #4810 (#4815)

This commit is contained in:
John Bodley 2018-04-12 10:41:36 -07:00 committed by Maxime Beauchemin
parent 683fb6c251
commit 2a95d203ad
2 changed files with 31 additions and 11 deletions

21
superset/assets/package-lock.json generated Normal file
View File

@ -0,0 +1,21 @@
{
"name": "superset",
"version": "0.23.0dev",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"node": {
"version": "9.11.0",
"resolved": "https://registry.npmjs.org/node/-/node-9.11.0.tgz",
"integrity": "sha512-a4HV43+rHSgYaoGVr5PfnpTmiDeL4AmFsXKzRhBbkDLeRjBoQYENHs7mNCHlQRb9VFKRqXD5FDmadQFPznkUuQ==",
"requires": {
"node-bin-setup": "1.0.6"
}
},
"node-bin-setup": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.0.6.tgz",
"integrity": "sha512-uPIxXNis1CRbv1DwqAxkgBk5NFV3s7cMN/Gf556jSw6jBvV7ca4F9lRL/8cALcZecRibeqU+5dFYqFFmzv5a0Q=="
}
}
}

View File

@ -12,7 +12,6 @@ down_revision = 'e68c4473c581'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError
from superset.utils import generic_find_uq_constraint_name
@ -25,9 +24,6 @@ names = {
'metrics': 'metric_name',
}
bind = op.get_bind()
insp = sa.engine.reflection.Inspector.from_engine(bind)
def upgrade():
@ -60,13 +56,16 @@ def downgrade():
)
# Remove the previous missing uniqueness constraints.
bind = op.get_bind()
insp = sa.engine.reflection.Inspector.from_engine(bind)
for table, column in names.items():
with op.batch_alter_table(table, naming_convention=conv) as batch_op:
batch_op.drop_constraint(
generic_find_uq_constraint_name(
table,
{column, 'datasource_id'},
insp,
) or 'uq_{}_{}'.format(table, column),
type_='unique',
)
generic_find_uq_constraint_name(
table,
{column, 'datasource_id'},
insp,
) or 'uq_{}_{}'.format(table, column),
type_='unique',
)