Opened 12 years ago
Closed 12 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.
Change History (2)
comment:1 by , 12 years ago
Owner: | set to |
---|---|
Status: | new → accepted |
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
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!
Just to update the bug:
Suggested patch in elrond/sql/fix_unique_migration