Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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)

23131.diff (845 bytes ) - added by Tim Graham 10 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Tim Graham, 10 years ago

Component: MigrationsDocumentation
Summary: Potential problems with field callables copyed to migrationsDocument caveats with callable references in migrations
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

I believe we'll just want to document the caveats here. docs/topics/migrations/#serializing-values looks like a reasonable place to do so.

comment:2 by Piotr Maliński, 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 Tim Graham, 10 years ago

Attachment: 23131.diff added

comment:3 by Tim Graham, 10 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 50ae4b4b9e146848ce0d95e76662ec0cf667fbe6:

Fixed #23131 -- Documented serialization of callable functions in migrations.

comment:5 by Tim Graham <timograham@…>, 10 years ago

In 8c8ce2ee64b098dc52ebda7ce95644cb7c2f9cb2:

[1.7.x] Fixed #23131 -- Documented serialization of callable functions in migrations.

Backport of 50ae4b4b9e from master

Note: See TracTickets for help on using tickets.
Back to Top