diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-07-29 10:02:59 -0700 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-07-29 10:02:59 -0700 |
| commit | 8ebd6d35d77c1c535a9ffe8151445ad853845b61 (patch) | |
| tree | 173f075e3041e520036b107a0eb808db9c7f0ad1 | |
| parent | a338e0773592ce4030407428c77815a713b6c9c7 (diff) | |
Fixed #23090: Document and enforce not double-squashing migrations
| -rw-r--r-- | django/core/management/commands/squashmigrations.py | 2 | ||||
| -rw-r--r-- | docs/topics/migrations.txt | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py index 82d8fcdca8..b3b2081fcf 100644 --- a/django/core/management/commands/squashmigrations.py +++ b/django/core/management/commands/squashmigrations.py @@ -65,6 +65,8 @@ class Command(BaseCommand): # Load the operations from all those migrations and concat together operations = [] for smigration in migrations_to_squash: + if smigration.replaces: + raise CommandError("You cannot squash squashed migrations! Please transition it to a normal migration first: https://docs.djangoproject.com/en/1.7/topics/migrations/#squashing-migrations") operations.extend(smigration.operations) if self.verbosity > 0: diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt index 80a86dee20..c9d6ee0e5d 100644 --- a/docs/topics/migrations.txt +++ b/docs/topics/migrations.txt @@ -487,6 +487,23 @@ please `file a bug report <https://code.djangoproject.com/newticket>`_ either way detailing the models and their relationships so we can improve the optimizer to handle your case. +Once you've squashed your migration, you should then commit it alongside the +migrations it replaces and distribute this change to all running instances +of your application, making sure that they run ``migrate`` to store the change +in their database. + +After this has been done, you must then transition the squashed migration to +a normal initial migration, by: + +- Deleting all the migration files it replaces +- Removing the ``replaces`` argument in the ``Migration`` class of the + squashed migration (this is how Django tells that it is a squashed migration) + +.. note:: + Once you've squashed a migration, you should not then re-squash that squashed + migration until you have fully transitioned it to a normal migration. + + .. _migration-serializing: Serializing values |
