Add unique constraint to story_tags table
This is a mapping table, we should not have duplicate entries Change-Id: I5b4548bdd39b9855919653b701efc5f357233a9f
This commit is contained in:
parent
9919a62912
commit
09305f8248
@ -0,0 +1,23 @@
|
|||||||
|
"""update story_tag table
|
||||||
|
|
||||||
|
Revision ID: acca67ec622b
|
||||||
|
Revises: 183755ac91df
|
||||||
|
Create Date: 2017-11-27 10:49:04.902131
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'acca67ec622b'
|
||||||
|
down_revision = '183755ac91df'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_index(op.f('story_tag_unique'), 'story_tag',
|
||||||
|
['story_key', 'tag_key'], unique=True)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
pass
|
@ -146,6 +146,7 @@ story_tag_table = Table(
|
|||||||
Column('key', Integer, primary_key=True),
|
Column('key', Integer, primary_key=True),
|
||||||
Column('story_key', Integer, ForeignKey("story.key"), index=True),
|
Column('story_key', Integer, ForeignKey("story.key"), index=True),
|
||||||
Column('tag_key', Integer, ForeignKey("tag.key"), index=True),
|
Column('tag_key', Integer, ForeignKey("tag.key"), index=True),
|
||||||
|
UniqueConstraint('story_key', 'tag_key', name='story_tag_unique'),
|
||||||
)
|
)
|
||||||
task_table = Table(
|
task_table = Table(
|
||||||
'task', metadata,
|
'task', metadata,
|
||||||
|
Loading…
Reference in New Issue
Block a user