Skip to content

Commit

Permalink
Fix index on Attribute
Browse files Browse the repository at this point in the history
Previously the index was unique among site and name. Add resource_name
since making Attribute more generic
  • Loading branch information
gmjosack committed Jan 23, 2015
1 parent 6ee2b77 commit 4708ac2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions nsot/migrations/versions/2693d64d08b6_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""empty message
Revision ID: 2693d64d08b6
Revises: 5678f0574a6d
Create Date: 2015-01-23 10:43:13.085148
"""

# revision identifiers, used by Alembic.
revision = '2693d64d08b6'
down_revision = '5678f0574a6d'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_index('name_idx', table_name='attributes')
op.create_index('name_idx', 'attributes', ['site_id', 'resource_name', 'name'], unique=True)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_index('name_idx', table_name='attributes')
op.create_index('name_idx', 'attributes', ['site_id', 'name'], unique=1)
### end Alembic commands ###
2 changes: 1 addition & 1 deletion nsot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ class Attribute(Model):
__table_args__ = (
Index(
"name_idx",
"site_id", "name",
"site_id", "resource_name", "name",
unique=True
),
)
Expand Down

0 comments on commit 4708ac2

Please sign in to comment.