Browse Source

Add unique constraint to story_tags table

This is a mapping table, we should not have duplicate entries

Change-Id: I5b4548bdd39b9855919653b701efc5f357233a9f
changes/05/523205/1
James E. Blair 3 years ago
parent
commit
09305f8248
2 changed files with 24 additions and 0 deletions
  1. +23
    -0
      boartty/alembic/versions/acca67ec622b_update_story_tag_table.py
  2. +1
    -0
      boartty/db.py

+ 23
- 0
boartty/alembic/versions/acca67ec622b_update_story_tag_table.py 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

+ 1
- 0
boartty/db.py 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,


Loading…
Cancel
Save