Skip to content

Commit

Permalink
fix: Alembic migration 18532d70ab98 (apache#11136)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and auxten committed Nov 20, 2020
1 parent 972140e commit 84670dd
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@

from alembic import op
from sqlalchemy.dialects.mysql.base import MySQLDialect
from sqlalchemy.engine.reflection import Inspector

from superset.utils.core import generic_find_uq_constraint_name


def upgrade():
bind = op.get_bind()

# Uniqueness constraint if present only exists in MySQL.
if isinstance(bind.dialect, MySQLDialect):
# index only exists in mysql db
with op.get_context().autocommit_block():
op.drop_constraint("table_name", "tables", type_="unique")
constraint_name = generic_find_uq_constraint_name(
"tables", {"table_name"}, Inspector.from_engine(bind)
)

if constraint_name:
op.drop_constraint(constraint_name, "tables", type_="unique")


def downgrade():
Expand Down

0 comments on commit 84670dd

Please sign in to comment.