Skip to content

Commit

Permalink
fix(docs): Touch ups to migration trimming docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlissner committed May 24, 2021
1 parent e03b1a9 commit f641d71
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/topics/migrations.txt
Expand Up @@ -656,10 +656,10 @@ The easiest and most reliable way to trim migrations is to do so manually,
instead of using the ``squashmigrations`` command. When doing this process, any
apps that have foreign key interdependencies will need to be trimmed at the same
time so that old migrations do not depend on deleted migrations. For example,
if your ``pizza`` app has an ``Ingredients`` model in your ``food`` app, you
will need to manually trim both the ``food`` and the ``pizza`` apps
simultaneously. It is often easiest to trim all apps in your project at the
same time.
if your ``pizza`` app has a ``ForeignKey`` to an ``Ingredients`` model in your
``food`` app, you will need to manually trim both the ``food`` and the
``pizza`` apps simultaneously. It is often easiest to trim all apps in your
project at the same time.

Once you have identified the apps you plan to trim, ensure that all of your
installations of your project are up to date with the same migrations and
Expand Down Expand Up @@ -688,17 +688,17 @@ Next, save any data or SQL migrations that you have. Find these migrations by
searching for ``RunPython`` and ``RunSQL`` in your migration files, and copy
anything you find to a temporary file.

Delete all of the migrations in the affected apps with something like::
Delete all of the migrations in the affected apps. In a Unix system the
following will generally work::

$ cd my_app1
$ find . -path "migrations/*.py" -not -name "__init__.py" -delete

Create a fresh migration for each app with::
Create a fresh migration for each app::

$ ./manage.py makemigrations

For any app that had data or SQL migrations, recreate empty migration files with
with::
For any app that had data or SQL migrations, recreate empty migration files::

$ ./manage.py makemigrations --empty my_app1 my_app2

Expand All @@ -710,12 +710,12 @@ database and any data migrations that you had prior to starting this process.

Because your database already has these changes applied by your old migrations,
you do not need to actually migrate it, but these migrations do need to be
marked as applied. Thus, fake running them with::
marked as applied. Thus, fake running them::

$ ./manage.py migrate --fake

Finally, to verify that everything worked, check that the migration has been
applied successfully with::
applied successfully::

$ ./manage.py showmigrations

Expand Down

0 comments on commit f641d71

Please sign in to comment.