mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Fixing unique constraint in SqlaTable model (#360)
This commit is contained in:
parent
2d420eee25
commit
01c2c7baf8
@ -0,0 +1,25 @@
|
||||
"""change_table_unique_constraint
|
||||
|
||||
Revision ID: b4456560d4f3
|
||||
Revises: bb51420eaf83
|
||||
Create Date: 2016-04-15 08:31:26.249591
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b4456560d4f3'
|
||||
down_revision = 'bb51420eaf83'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_constraint(
|
||||
u'tables_table_name_key', 'tables', type_='unique')
|
||||
op.create_unique_constraint(
|
||||
u'_customer_location_uc', 'tables',
|
||||
['database_id', 'schema', 'table_name'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(u'_customer_location_uc', 'tables', type_='unique')
|
@ -406,7 +406,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||
|
||||
__tablename__ = 'tables'
|
||||
id = Column(Integer, primary_key=True)
|
||||
table_name = Column(String(250), unique=True)
|
||||
table_name = Column(String(250))
|
||||
main_dttm_col = Column(String(250))
|
||||
description = Column(Text)
|
||||
default_endpoint = Column(Text)
|
||||
@ -422,6 +422,11 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||
|
||||
baselink = "tablemodelview"
|
||||
|
||||
__table_args__ = (
|
||||
sqla.UniqueConstraint(
|
||||
'database_id', 'schema', 'table_name',
|
||||
name='_customer_location_uc'),)
|
||||
|
||||
def __repr__(self):
|
||||
return self.table_name
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user