Document caveats with callable references in migrations
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?
Change History
(6)
| 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
|
| 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.