Opened 11 years ago
Last modified 11 years ago
#914 closed defect
Use named ForeignKeys in migrations — at Version 2
| Reported by: | Elrond | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | 0.8.0 |
| Component: | programming | Keywords: | test |
| Cc: | Parent Tickets: |
Description (last modified by )
db/migrations.py has this:
from mediagoblin.db.models import (MediaEntry, Collection, MediaComment, User,
Privilege)
This is a big NO! Those are the current variansts of those tables. Not the versions needed in any old migration. Those current tables could have changed in a completely unexpected way and break old migrations.
If there are migration docs, please add a note about this.
The current main use of the above imports is code like this:
creator = Column(Integer, ForeignKey(User.id), nullable=False)
This can be easily fixed:
creator = Column(Integer, ForeignKey('core__users.id'), nullable=False)
When this is done, please take a look at add_new_notification_tables():
user_table = inspect_table(metadata, 'core__users')
mediaentry_table = inspect_table(metadata, 'core__media_entries')
mediacomment_table = inspect_table(metadata, 'core__media_comments')
This code might be useless.
After fixing all of this, please make sure the migrations still work.
Change History (2)
comment:1 by , 11 years ago
| Keywords: | test added |
|---|
comment:2 by , 11 years ago
| Description: | modified (diff) |
|---|
