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:
James E. Blair 2017-11-27 11:19:16 -08:00
parent 9919a62912
commit 09305f8248
2 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -146,6 +146,7 @@ story_tag_table = Table(
Column('key', Integer, primary_key=True),
Column('story_key', Integer, ForeignKey("story.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', metadata,