Normally, the data migration does not perform any external code that would
automatically modify data (for example, own method of "save").
However, it auto_now made during migration automatic changes in the data,
which seems to me not consistent with the idea of data migration.
During data migration there should be no any automatic changes to the
data, at least I think so.
So I proposed to remove action auto_now and / or auto_now_add during
migration.
--
Ticket URL: <https://code.djangoproject.com/ticket/26984>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hi fizista,
I'm not sure I understand your request.
Using `auto_now` (just like any other `default` option) result in usage of
`DEFAULT` in `ADD FIELD` operations which is required when adding `NOT
NULL` fields (e.g. `DateTimeField(auto_now=True)`). What should be done
when such a column is added if we were to drop support for `default`
altogether?
--
Ticket URL: <https://code.djangoproject.com/ticket/26984#comment:1>
Comment (by charettes):
Or maybe you are suggesting that `auto_now` and `auto_now_add` shouldn't
be effective in data migrations (e.g. `RunPython`?).
If that's the case I'm inclined to close this as ''wontfix'' since a lot
of efforts are made to make sure models provided in data migrations behave
exactly like normal models do.
--
Ticket URL: <https://code.djangoproject.com/ticket/26984#comment:2>
Comment (by fizista):
Yes, I mean operations run in the "RunPython".
We can always use the "update_fields" in the method save.
--
Ticket URL: <https://code.djangoproject.com/ticket/26984#comment:3>
* status: new => closed
* resolution: => wontfix
Comment:
I'll resolve as ''wontfix'' in this case as migrations were designed to
carry model state around in order to make models available through
`RunPython` operations behave just like normal models would at certain
point in a project.
I see no compelling reason to make `auto_now` or `auto_now_add` behave
differently when used in data migrations.
--
Ticket URL: <https://code.djangoproject.com/ticket/26984#comment:4>