[Django] #22445: Doc on reversible data migrations needed

151 views
Skip to first unread message

Django

unread,
Apr 15, 2014, 10:55:23 AM4/15/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
-------------------------------------------+----------------------------
Reporter: kmtracey | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.7-beta-1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+----------------------------
If I create a data migration, run it, then try to migrate back to before
it, I get:

{{{
Unapplying m3app.0003_auto_20140415_1022...Traceback (most recent call
last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/core/management/__init__.py", line 427, in
execute_from_command_line
utility.execute()
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/core/management/base.py", line 337, in execute
output = self.handle(*args, **options)
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/core/management/commands/migrate.py", line 145, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/db/migrations/executor.py", line 62, in migrate
self.unapply_migration(migration, fake=fake)
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/db/migrations/executor.py", line 114, in unapply_migration
migration.unapply(project_state, schema_editor)
File "/home/kmtracey/.virtualenvs/uncfm/lib/python3.3/site-
packages/django/db/migrations/migration.py", line 121, in unapply
raise Migration.IrreversibleError("Operation %s in %s is not
reversible" % (operation, self))
django.db.migrations.migration.IrreversibleError: Operation <RunPython
<function load_initial_data at 0x7f7af2424050>> in
m3app.0003_auto_20140415_1022 is not reversible
}}}

I cannot find any documentation on how to create a reversible data
migration. I'm used to doing this with South, I assume there is some way
to do this in the new migrations framework? We need some doc on how to do
it...or if this is not just a missing doc issue then this needs to be re-
classified as a migrations code issue...

--
Ticket URL: <https://code.djangoproject.com/ticket/22445>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 15, 2014, 11:19:09 AM4/15/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
---------------------------------+--------------------------------------

Reporter: kmtracey | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.7-beta-1
Severity: Release blocker | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by kmtracey):

Peeking at the code reveals !RunPython can be handed a 2nd callable to do
the "reverse" operation. So I think this doc:

https://docs.djangoproject.com/en/1.7/topics/migrations/#data-migrations

specifically needs to be updated to include mention of that, at a minimum.

--
Ticket URL: <https://code.djangoproject.com/ticket/22445#comment:1>

Django

unread,
Apr 15, 2014, 1:56:03 PM4/15/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
---------------------------------+--------------------------------------

Reporter: kmtracey | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.7-beta-1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by charettes):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22445#comment:2>

Django

unread,
Apr 27, 2014, 2:21:35 PM4/27/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
---------------------------------+--------------------------------------
Reporter: kmtracey | Owner: timo
Type: Bug | Status: assigned
Component: Documentation | Version: 1.7-beta-1

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by timo):

* status: new => assigned
* owner: nobody => timo


--
Ticket URL: <https://code.djangoproject.com/ticket/22445#comment:3>

Django

unread,
Apr 27, 2014, 3:17:25 PM4/27/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
---------------------------------+--------------------------------------
Reporter: kmtracey | Owner: timo
Type: Bug | Status: assigned
Component: Documentation | Version: 1.7-beta-1

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by timo):

It's covered in the [https://docs.djangoproject.com/en/1.7/ref/migration-
operations/#runpython RunPython reference], but I will add a couple
sentences to the topic guide.

--
Ticket URL: <https://code.djangoproject.com/ticket/22445#comment:4>

Django

unread,
Apr 27, 2014, 3:21:14 PM4/27/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
---------------------------------+--------------------------------------
Reporter: kmtracey | Owner: timo
Type: Bug | Status: closed
Component: Documentation | Version: 1.7-beta-1
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1ce759b69f641fd780790630c79559fc68a2d923"]:
{{{
#!CommitTicketReference repository=""
revision="1ce759b69f641fd780790630c79559fc68a2d923"
Fixed #22445 -- Added how to perform a reverse data migration to topic
guide.

Thanks Karen Tracey for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22445#comment:5>

Django

unread,
Apr 27, 2014, 3:21:28 PM4/27/14
to django-...@googlegroups.com
#22445: Doc on reversible data migrations needed
---------------------------------+--------------------------------------
Reporter: kmtracey | Owner: timo
Type: Bug | Status: closed
Component: Documentation | Version: 1.7-beta-1

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"23f3c53aff54b7f298f29e97042d00dbd9379d00"]:
{{{
#!CommitTicketReference repository=""
revision="23f3c53aff54b7f298f29e97042d00dbd9379d00"
[1.7.x] Fixed #22445 -- Added how to perform a reverse data migration to
topic guide.

Thanks Karen Tracey for the report.

Backport of 1ce759b69f from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22445#comment:6>

Reply all
Reply to author
Forward
0 new messages