From 1d5e0fc29ad06d8d8b9da7cffd0fa6bd97658be4 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Sat, 25 Aug 2018 14:46:28 -0700 Subject: [PATCH 1/2] Silence error on migration 4736ec66ce19 constraint drop --- superset/migrations/versions/4736ec66ce19_.py | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/superset/migrations/versions/4736ec66ce19_.py b/superset/migrations/versions/4736ec66ce19_.py index 280132d61ec8..e0b76f034abd 100644 --- a/superset/migrations/versions/4736ec66ce19_.py +++ b/superset/migrations/versions/4736ec66ce19_.py @@ -101,16 +101,24 @@ def upgrade(): batch_op.drop_column('datasource_name') - # Drop the old more restrictive uniqueness constraint. - with op.batch_alter_table('datasources', naming_convention=conv) as batch_op: - batch_op.drop_constraint( - generic_find_uq_constraint_name( - 'datasources', - {'datasource_name'}, - insp, - ) or 'uq_datasources_datasource_name', - type_='unique', - ) + try: + # Drop the old more restrictive uniqueness constraint. + with op.batch_alter_table('datasources', naming_convention=conv) as batch_op: + batch_op.drop_constraint( + generic_find_uq_constraint_name( + 'datasources', + {'datasource_name'}, + insp, + ) 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(): From 17bb6f33353cfe603a9290412a700c643f6c8fb1 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 27 Aug 2018 21:30:37 -0700 Subject: [PATCH 2/2] typo + lint --- superset/migrations/versions/4736ec66ce19_.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/superset/migrations/versions/4736ec66ce19_.py b/superset/migrations/versions/4736ec66ce19_.py index e0b76f034abd..4cb79595fb32 100644 --- a/superset/migrations/versions/4736ec66ce19_.py +++ b/superset/migrations/versions/4736ec66ce19_.py @@ -7,13 +7,10 @@ """ -# revision identifiers, used by Alembic. -revision = '4736ec66ce19' -down_revision = 'f959a6652acd' +import logging from alembic import op import sqlalchemy as sa -from sqlalchemy.exc import OperationalError from superset.utils import ( generic_find_fk_constraint_name, @@ -21,6 +18,9 @@ generic_find_uq_constraint_name, ) +# revision identifiers, used by Alembic. +revision = '4736ec66ce19' +down_revision = 'f959a6652acd' conv = { 'fk': 'fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s', @@ -114,10 +114,10 @@ def upgrade(): ) 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.") + '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)