From b538743beed9f82ce61be4151de9010caf1774b8 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 28 Nov 2017 08:39:12 -0800 Subject: [PATCH 1/2] fix 'superset db history' Related Error msg when running `superset db history`: "NameError: Can't invoke function 'get_bind', as the proxy object has not yet been established for the Alembic 'Operations' class. Try placing this code inside a callable." --- superset/migrations/versions/4736ec66ce19_.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/superset/migrations/versions/4736ec66ce19_.py b/superset/migrations/versions/4736ec66ce19_.py index 2d560d57dfd21..ed6a25ccb17a5 100644 --- a/superset/migrations/versions/4736ec66ce19_.py +++ b/superset/migrations/versions/4736ec66ce19_.py @@ -34,12 +34,13 @@ sa.Column('datasource_name', sa.String(255)), ) -bind = op.get_bind() -insp = sa.engine.reflection.Inspector.from_engine(bind) - def upgrade(): + bind = op.get_bind() + insp = sa.engine.reflection.Inspector.from_engine(bind) + + # Add the new less restrictive uniqueness constraint. with op.batch_alter_table('datasources', naming_convention=conv) as batch_op: batch_op.create_unique_constraint( @@ -114,6 +115,10 @@ def upgrade(): def downgrade(): + bind = op.get_bind() + insp = sa.engine.reflection.Inspector.from_engine(bind) + + # Add the new more restrictive uniqueness constraint which is required by # the foreign key constraints. Note this operation will fail if the From e3a79dc2ae31751d6d6c71fc5a0666d2d4ffc6b0 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 28 Nov 2017 17:51:18 -0800 Subject: [PATCH 2/2] Lint --- superset/migrations/versions/4736ec66ce19_.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/superset/migrations/versions/4736ec66ce19_.py b/superset/migrations/versions/4736ec66ce19_.py index ed6a25ccb17a5..de86a392292ad 100644 --- a/superset/migrations/versions/4736ec66ce19_.py +++ b/superset/migrations/versions/4736ec66ce19_.py @@ -36,11 +36,9 @@ def upgrade(): - bind = op.get_bind() insp = sa.engine.reflection.Inspector.from_engine(bind) - # Add the new less restrictive uniqueness constraint. with op.batch_alter_table('datasources', naming_convention=conv) as batch_op: batch_op.create_unique_constraint( @@ -118,8 +116,6 @@ def downgrade(): bind = op.get_bind() insp = sa.engine.reflection.Inspector.from_engine(bind) - - # Add the new more restrictive uniqueness constraint which is required by # the foreign key constraints. Note this operation will fail if the # datasources.datasource_name column is no longer unique.