#23131 closed Cleanup/optimization (fixed)
Document caveats with callable references in migrations
Reported by: | Piotr Maliński | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.7-rc-1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Model fields support callables in few places, like:
image = models.ImageField(db_index=True, upload_to=upload_path, blank=True)
where upload_path is a function. Migrating model with such field will give:
('image', models.ImageField(blank=True, upload_to=my_app.models.upload_path)),
That can easily cause problems. Future changes to the code (like different callable name) would break old migrations (which then would break tests). Does migrations must copy everything?
Attachments (1)
Change History (6)
comment:1 by , 10 years ago
Component: | Migrations → Documentation |
---|---|
Summary: | Potential problems with field callables copyed to migrations → Document caveats with callable references in migrations |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 10 years ago
Well, if so then in general those new migrations will require much more time for maintenance than south migrations. If such callable is changed then either migrations must be edited or squashed and edited. And there is more cases where new migrations make such problems.
by , 10 years ago
Attachment: | 23131.diff added |
---|
comment:3 by , 10 years ago
Has patch: | set |
---|
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I believe we'll just want to document the caveats here. docs/topics/migrations/#serializing-values looks like a reasonable place to do so.