fixing unique secondary and owner

This commit is contained in:
Cayo Puigdefabregas 2021-02-26 18:58:10 +01:00
parent ac032c7902
commit 8d6e50ece9
2 changed files with 5 additions and 1 deletions

View file

@ -24,9 +24,13 @@ def get_inv():
def upgrade():
op.drop_constraint('one tag id per organization', 'tag', schema=f'{get_inv()}')
op.drop_constraint('one secondary tag per organization', 'tag', schema=f'{get_inv()}')
op.create_primary_key('one tag id per owner', 'tag', ['id', 'owner_id'], schema=f'{get_inv()}'),
op.create_unique_constraint('one secondary tag per owner', 'tag', ['secondary', 'owner_id'], schema=f'{get_inv()}'),
def downgrade():
op.drop_constraint('one tag id per owner', 'tag', schema=f'{get_inv()}')
op.drop_constraint('one secondary tag per owner', 'tag', schema=f'{get_inv()}')
op.create_primary_key('one tag id per organization', 'tag', ['id', 'org_id'], schema=f'{get_inv()}'),
op.create_unique_constraint('one secondary tag per organization', 'tag', ['secondary', 'org_id'], schema=f'{get_inv()}'),

View file

@ -98,7 +98,7 @@ class Tag(Thing):
__table_args__ = (
UniqueConstraint(id, owner_id, name='one tag id per owner'),
UniqueConstraint(secondary, org_id, name='one secondary tag per organization')
UniqueConstraint(secondary, owner_id, name='one secondary tag per organization')
)
@property