Opened 8 months ago

Closed 7 months ago

Last modified 7 months ago

#23131 closed Cleanup/optimization (fixed)

Document caveats with callable references in migrations

Reported by: riklaunim 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 timgraham 7 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 8 months ago by timo

  • Component changed from Migrations to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Potential problems with field callables copyed to migrations to Document caveats with callable references in migrations
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/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 Changed 8 months ago by riklaunim

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.

Changed 7 months ago by timgraham

comment:3 Changed 7 months ago by timgraham

  • Has patch set

comment:4 Changed 7 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 50ae4b4b9e146848ce0d95e76662ec0cf667fbe6:

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

comment:5 Changed 7 months ago by Tim Graham <timograham@…>

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