> if the field is not nullable this may make this operation irreversible
(apart from any data loss, which of course is irreversible)
I find this sentence confusing.
The note in parentheses implies opposition with the previous statement
when it's in fact saying the same thing: the operation is irreversible.
[1] https://docs.djangoproject.com/en/dev/ref/migration-
operations/#django.db.migrations.operations.RemoveField
--
Ticket URL: <https://code.djangoproject.com/ticket/25917>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by rfleschenberg):
As I understand it, the sentence means this: if the field is not nullable,
the reverse of RemoveField (adding a field) may fail, because Django does
not know which data to add for existing rows.
Apart from that, the forward operation (removing the field) is of course
never reversible in so far as it deletes the data in the field.
Question: would RemoveField be reversible if the field has a default
value?
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:1>
Comment (by bmispelon):
If the field is not nullable, is there a case where the reverse of
`RemoveField` would not fail? If not, the use of "may" is confusing.
As for the question about `default`, that's a good point. I haven't tried
and it could make the reverse operation "work" in the sense that Django
would be able to get back to a valid state but there's no guarantee that
your data would be preserved (any non-default values for that column would
be gone).
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:2>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:3>
* owner: nobody => andersonresende
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:4>
Comment (by MarkusH):
If I see it correctly, unless Django has a value to put into a restored
column from a previous migration state (e.g. default, null) `RemoveField`
is irreversible.
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:5>
* owner: andersonresende =>
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:6>
Comment (by kaifeldhoff):
It seems like everything is pretty clear here and this ticket could be
finished. My suggestion for the respective section in the docs is below.
As I am not a native speaker, I appreciate feedback.
By the time everything is fine, I'd like to add this to the docs being my
first ticket.
''Bear in mind that when reversed this is actually adding a field to a
model. To make this possible, Django needs a default value to populate the
recreated empty column. This is only possible for a field that is nullable
or has a defined default value.
On the other hand if the field is not nullable and does not have a default
value, this operation is irreversible (apart from any data loss, which of
course is irreversible).''
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:7>
* owner: => kaifeldhoff
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:8>
* Attachment "25917.diff" added.
Based on e47f0c1 [1.9.x] Fixed #26136 ...
* has_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:9>
* needs_tests: 1 => 0
Comment:
Are you able to submit the patch as a pull request? That makes review
easier. Please wrap documentation at 79 characters too.
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:10>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"55481bcdeef43ef5e345f8ea3bae87f4a8ec7bb8" 55481bcd]:
{{{
#!CommitTicketReference repository=""
revision="55481bcdeef43ef5e345f8ea3bae87f4a8ec7bb8"
Fixed #25917 -- Clarified reversibility of RemoveField.
Thanks kaifeldhoff for the draft patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:11>
Comment (by Tim Graham <timograham@…>):
In [changeset:"6103b4990025656a649caad641abb135941f6bf4" 6103b499]:
{{{
#!CommitTicketReference repository=""
revision="6103b4990025656a649caad641abb135941f6bf4"
[1.9.x] Fixed #25917 -- Clarified reversibility of RemoveField.
Thanks kaifeldhoff for the draft patch.
Backport of 55481bcdeef43ef5e345f8ea3bae87f4a8ec7bb8 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:12>
Comment (by kaifeldhoff):
At least it helped!
I'm having trouble to get Sphinx to work, so I was still unsure about the
effect of wrapping the lines.
--
Ticket URL: <https://code.djangoproject.com/ticket/25917#comment:13>