Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25888 closed Bug (invalid)

migrate with "--fake" option modifies the database

Reported by: mandm Owned by: nobody
Component: Database layer (models, ORM) Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (4)

comment:1 by Sergey Fedoseev, 9 years ago

Resolution: invalid
Status: newclosed

This is intended behavior:

python manage.py help migrate
...
  --fake                Mark migrations as run without actually running them.
...

comment:2 by Josh Smeaton, 9 years ago

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

comment:3 by mandm, 9 years ago

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

comment:4 by Shai Berger, 9 years ago

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.

Note: See TracTickets for help on using tickets.
Back to Top