Skip to content

Commit

Permalink
Fixing unique constraint in SqlaTable model
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 15, 2016
1 parent 2d420ee commit b9099a8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
@@ -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')
7 changes: 6 additions & 1 deletion caravel/models.py
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit b9099a8

Please sign in to comment.