[Django] #25888: migrate with "--fake" option modifies the database

10 views
Skip to first unread message

Django

unread,
Dec 8, 2015, 2:58:23 AM12/8/15
to django-...@googlegroups.com
#25888: migrate with "--fake" option modifies the database
----------------------------------------------+--------------------
Reporter: mandm | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version:
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
I made a migration and tested it on development server. When I pushed the
changes to production server, I ran

{{{
manage.py migrate --fake
}}}

This printed the message that the migration was faked. After this, when I
actually tried to apply the migration with

{{{
manage.py migrate
}}}

I got a message `No migrations to apply`. (Indeed --list showed that the
migration was applied). I dumped the database and found that the migration
was marked as applied (in `django_migrations` table &
`django_migrations_id_seq` was incremented). However the actual change
that the migration was intended for, was not applied to the database.

I've tested this on PgSQL 9.4 & Django 1.7.

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

Django

unread,
Dec 8, 2015, 7:17:54 AM12/8/15
to django-...@googlegroups.com
#25888: migrate with "--fake" option modifies the database
-------------------------------------+-------------------------------------
Reporter: mandm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by sir-sigurd):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

This is intended behavior:
{{{
python manage.py help migrate
...
--fake Mark migrations as run without actually running
them.
...
}}}

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

Django

unread,
Dec 8, 2015, 8:09:35 AM12/8/15
to django-...@googlegroups.com
#25888: migrate with "--fake" option modifies the database
-------------------------------------+-------------------------------------
Reporter: mandm | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: invalid
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 jarshwah):

If you're looking to test the output of the migration perhaps you might
want to use the sqlmigrate command
https://docs.djangoproject.com/en/dev/ref/django-admin/#sqlmigrate-app-
label-migrationname

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

Django

unread,
Dec 8, 2015, 11:55:52 AM12/8/15
to django-...@googlegroups.com
#25888: migrate with "--fake" option modifies the database
-------------------------------------+-------------------------------------
Reporter: mandm | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: invalid
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 mandm):

Is there a way to undo `--fake` for manually created migrations file (if
`reverse_sql` isn't available) ?

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

Django

unread,
Dec 8, 2015, 7:34:43 PM12/8/15
to django-...@googlegroups.com
#25888: migrate with "--fake" option modifies the database
-------------------------------------+-------------------------------------
Reporter: mandm | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: invalid
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 shaib):

You can use `--fake` also when migrating backwards, thus undoing your
original `--fake` (but beware if you have other migrations depending on
your migration). How you created the migration file is irrelevant.

In the future, please use the designated support channels (IRC channel
#django on freenode, or django-users mailing list) rather than the bug
tracker for this kind of question.

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

Reply all
Reply to author
Forward
0 new messages