diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2015-02-12 12:48:28 +0100 |
|---|---|---|
| committer | Markus Holtermann <info@markusholtermann.eu> | 2015-02-13 15:21:10 +0100 |
| commit | bd80fa6b0f7e5a0cc4ea26cedd56d0c4c4894420 (patch) | |
| tree | 8ce4c4f1532fe8c177115eca6714096247bcae16 /django/core | |
| parent | 4ba7d73f94b47abfb5f90ac223973bcd64466e80 (diff) | |
[1.8.x] Fixed #24184 -- Prevented automatic soft-apply of migrations
Previously Django only checked for the table name in CreateModel
operations in initial migrations and faked the migration automatically.
This led to various errors and unexpected behavior. The newly introduced
--fake-initial flag to the migrate command must be passed to get the
same behavior again. With this change Django will bail out in with a
"duplicate relation / table" error instead.
Thanks Carl Meyer and Tim Graham for the documentation update, report
and review.
Backport of f287bec5833d75750fa6368bc2802741b7924533 from master
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/management/commands/migrate.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py index 89f32bdc3d..f623836c60 100644 --- a/django/core/management/commands/migrate.py +++ b/django/core/management/commands/migrate.py @@ -45,6 +45,10 @@ class Command(BaseCommand): 'Defaults to the "default" database.') parser.add_argument('--fake', action='store_true', dest='fake', default=False, help='Mark migrations as run without actually running them') + parser.add_argument('--fake-initial', action='store_true', dest='fake_initial', default=False, + help='Detect if tables already exist and fake-apply initial migrations if so. Make sure ' + 'that the current database schema matches your initial migration before using this ' + 'flag. Django will only check for an existing table name.') parser.add_argument('--list', '-l', action='store_true', dest='list', default=False, help='Show a list of all known migrations and which are applied') @@ -212,7 +216,9 @@ class Command(BaseCommand): "apply them." )) else: - executor.migrate(targets, plan, fake=options.get("fake", False)) + fake = options.get("fake") + fake_initial = options.get("fake_initial") + executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) # Send the post_migrate signal, so individual apps can do whatever they need # to do at this point. |
