diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 037eb779a03d7..b137f80a9fe43 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -262,7 +262,7 @@ class SqlaTable(Model, BaseDatasource): column_class = TableColumn __tablename__ = 'tables' - __table_args__ = (UniqueConstraint('database_id', 'table_name'),) + __table_args__ = (UniqueConstraint('database_id', 'schema', 'table_name'),) table_name = Column(String(250)) main_dttm_col = Column(String(250)) diff --git a/superset/migrations/versions/d6a223d2332a_add_one_more_constraint.py b/superset/migrations/versions/d6a223d2332a_add_one_more_constraint.py new file mode 100644 index 0000000000000..6dd8d0acf5d39 --- /dev/null +++ b/superset/migrations/versions/d6a223d2332a_add_one_more_constraint.py @@ -0,0 +1,25 @@ +"""add one more constraint + +Revision ID: d6a223d2332a +Revises: 55e910a74826 +Create Date: 2018-09-19 16:51:55.900887 + +""" + +# revision identifiers, used by Alembic. +revision = 'd6a223d2332a' +down_revision = '55e910a74826' + +from alembic import op + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_unique_constraint(None, 'tables', ['database_id', 'schema', 'table_name']) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'tables', type_='unique') + # ### end Alembic commands ###