Opened 8 years ago

Closed 8 years ago

#550 closed defect (fixed)

Fix missing constraint in recent migrations

Reported by: Christopher Allan Webber Owned by: Elrond
Priority: blocker Milestone: 0.3.2
Component: programming Keywords:
Cc: Elrond Parent Tickets:

Description

A recent migration added a table for the CollectionItem model but didn't add the constraint of:

    __table_args__ = (
        UniqueConstraint('collection', 'media_entry'),
        {})

Since then we've moved to a new style of "creating models in migrations" which involves actually putting a copy of the original model inside the migrations file to make it easier to create the right database. However, anyone running from git master will currently pick up the "mistaken" commit.

There basically seem to be one of two possible solutions:

  • One, try to create a migration that's "smart"-ish. We can't check for constraints... sqlalchemy doesn't have support for that... but we could maybe try adding the constraint and just catch the exception if it isn't allowed?
  • That might not work though (and it does feel a bit "icky"). If it doesn't, we should simply correct the old migration and also create scripts that will add the constraint for people who may have picked up the bad migration from git master.

Subtickets

Change History (2)

comment:1 Changed 8 years ago by Elrond

Owner: set to Elrond
Status: newaccepted

Just to update the bug:

Suggested patch in elrond/sql/fix_unique_migration

comment:2 Changed 8 years ago by Christopher Allan Webber

Resolution: fixed
Status: acceptedclosed

Merged. I removed the print statements as discussed on IRC... good idea, but we just don't have a nice mechanism for presenting them, and at present it's kind of confusing to users.

Thanks SO MUCH for catching and fixing, Elrond!

Note: See TracTickets for help on using tickets.