Skip to content

Commit 7dca51a

Browse files
committed
doc: update README with new command name
1 parent db7a879 commit 7dca51a

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
# django-replace-migrations
1+
# gg-django-replace-migrations
22

3-
This package is an extension to djangos `makemigrations.py`.
4-
It can be used to get rid of old migrations as an alternative to djangos `squashmigration` command.
3+
This package offers a new django command: `replace_all_migrations`.
4+
It can be use to get rid of old migrations as an alternative to django's `squashmigration` command.
55

66
## Reasoning
77

88
In big django projects, migration files easily pile up and get an increasing problem.
9-
Django comes with the squashmigration command - however, it is hard to handle because of multiple reasons.
10-
Especially, it can not handle circular dependencies - they must be resolved [manually and with great care](https://stackoverflow.com/questions/37711402/circular-dependency-when-squashing-django-migrations).
9+
Django comes with the squashmigration command - however, it is hard to handle because of multiple reasons. Especially, it can not handle circular dependencies - they must be resolved [manually and with great care](https://stackoverflow.com/questions/37711402/circular-dependency-when-squashing-django-migrations).
1110

1211
One possible solution is to:
1312

@@ -17,13 +16,11 @@ One possible solution is to:
1716

1817
This workflow might work fine, if you have only few (production) servers - however, it becomes hard, when you have many environments with different versions of your application.
1918

20-
With django-replace-migrations also creates new initial migrations, but also, additionally, adds the already existing migrations to the `replace` list of the new migration
21-
(That list is used by `squashmigrations` as well). By doing that, faking migrations is not needed anymore.
19+
gg-django-replace-migrations also creates new initial migrations, but also, additionally, it adds the already existing migrations to the `replace` list of the new migration (That list is used by `squashmigrations` as well). By doing that, faking migrations is not needed anymore.
2220

2321
## Warning
2422

25-
The new replacing migrations will not consider any `RunPython` or `RunSQL` operations.
26-
That might be acceptable depending on your use of those operations and if you need those to prepare a fresh database.
23+
The new replacing migrations will add not elidable special operations (`RunPython`, `RunSQL` or `SeparateDatabaseAndState`) at the end of the squash files. You will have to manually add them when suitable.
2724

2825
## Installation
2926

@@ -32,20 +29,26 @@ Before you install, read the workflow below. You need to have the app installed
3229
Run
3330

3431
```
35-
pip install django-replace-migrations
32+
pip install gg-django-replace-migrations
3633
```
3734

38-
and add `django_replace_migrations` to your list of installed apps.
35+
and add `gg_django_replace_migrations` to your list of installed apps.
3936

4037
## Simple Workflow
4138

4239
If your apps are not depending on each other, you can use django-replace-migrations like this:
4340

4441
```
45-
./manage.py makemigratons --replace-all --name replace [app1, app2, ...]
42+
./manage.py replace_all_migrations --name replace [app1, app2, ...]
43+
```
44+
45+
Note, that you will need to list all of your apps explicitly - otherwise django will also try to replace migrations from dependencies:
46+
47+
```
48+
from django.apps import apps
49+
print(" ".join(map(str, sorted({model._meta.app_label for model in apps.get_models()}))))
4650
```
4751

48-
Note, that you will need to [list all of your apps](https://stackoverflow.com/questions/4111244/get-a-list-of-all-installed-applications-in-django-and-their-attributes) explicitly - otherwise django will also try to replace migrations from dependencies.
4952
While `--name` could be omitted, it is highly recommended to use it so that you can easily recognize the new migrations.
5053

5154
If for any of your apps there are not one but two or more migrations created, your apps are depending on each other (see below).
@@ -70,8 +73,8 @@ The workflow for this would be:
7073
- commit and note the commit hash
7174
- `git checkout 2.0`
7275
- create a new branch `git checkout -b 2-0-replace-migrations`
73-
- Install `django-replace-migration` here.
74-
- run `./manage.py makemigrations --replace-all --name replace_2_0 app1, app2, ...` ([How to get all apps](https://stackoverflow.com/questions/4111244/get-a-list-of-all-installed-applications-in-django-and-their-attributes))
76+
- Install `gg-django-replace-migration` here.
77+
- run `./manage.py replace_all_migrations --name replace_2_0 app1, app2, ...` ([How to get all apps](https://stackoverflow.com/questions/4111244/get-a-list-of-all-installed-applications-in-django-and-their-attributes))
7578
- commit and note the commit hash
7679
- `git checkout [your main/feature branch]`
7780
- `git cherry-pick [commit-hash from 2-0-delete-migrations]`
@@ -87,7 +90,3 @@ If your app is below 2.0 and you want to update to something after 2.0, you firs
8790
- upgrading from 1.0 to 1.5 will be possible
8891
- upgrading from 2.0 to 3.0 will be possible
8992
- upgrading from 1.0 to 3.0 will be **not** possible
90-
91-
## `makemigration.py` compatibility
92-
93-
This package requires deep integration into `makemigrations.py` so that I needed to copy the whole `makemigrations.py` here. Currently the version of `makemigrations.py` is copied from Django 2.1, however it is also tested with Django 3.0 and works there as well. If you encounter problems, please write what version of Django you are using.

0 commit comments

Comments
 (0)