You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# django-replace-migrations
2
2
3
3
This package is an extension to djangos `makemigrations.py`.
4
-
It can be used to get rid of old migrations as alternative to djangos `squashmigration` command.
4
+
It can be used to get rid of old migrations as an alternative to djangos `squashmigration` command.
5
5
6
6
## Reasoning
7
7
8
-
In big django projects, migration files easily pile up and get a increasing problem.
8
+
In big django projects, migration files easily pile up and get an increasing problem.
9
9
Django comes with the squashmigration command - however, it is hard to handle because of multiple reasons.
10
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).
11
11
@@ -18,7 +18,7 @@ One possible solution is to:
18
18
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.\
19
19
20
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 `squashmigratiions` as well). By doing that, faking migrations is not needed anymore.
21
+
(That list is used by `squashmigrations` as well). By doing that, faking migrations is not needed anymore.
22
22
23
23
## Warning
24
24
@@ -45,20 +45,20 @@ If your apps are not depending on each other, you can use django-replace-migrati
Note, that you will need to list all of your apps explicitly - otherwise django will also try to replace migrations from dependencies.
48
-
While `--name` could be omited, it is highly recommended to use it so that you can easlily recognize the new migrations.
48
+
While `--name` could be omitted, it is highly recommended to use it so that you can easily recognize the new migrations.
49
49
50
50
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).
51
51
52
-
You can leave your old migrations in the codebase. Old versons will continue to use the old migrations, while fresh installations will use the newly created replace migration instead.
52
+
You can leave your old migrations in the codebase. Old versions will continue to use the old migrations, while fresh installations will use the newly created replace migration instead.
53
53
54
-
If you remove the old migrations later, you will need to update the dependencies in your other migrations and repalce there all ocurances of the old migration with the new replace migration. You can easily do that with try-and-error (`migrate` will fail and tell you which dependency is missing)
54
+
If you remove the old migrations later, you will need to update the dependencies in your other migrations and replace all occurrences of the old migration with the new replace migration. You can easily do that with try-and-error (`migrate` will fail and tell you which dependency is missing)
55
55
56
56
57
57
## Workflow for depending apps
58
58
59
59
Due to the way django resolves the `replace` list, it can not handle circular dependencies within apps. To prevent an error during migration, you must delete the old migrations that you replaced.
60
60
61
-
If you have your application deployed on multiple servers, you must define down to which version, you will support upgrading and only replace those migratons.
61
+
If you have your application deployed on multiple servers, you must define down to which version, you will support upgrading and only replace those migrations.
62
62
63
63
Let’s assume that our current version of the application is 3.0 and we want to get rid of all migrations prior to 2.0.
64
64
@@ -70,11 +70,11 @@ The workflow for this would be:
70
70
* commit and note the commit hash
71
71
*`git checkout 2.0`
72
72
* create a new branch `git checkout 2-0-replace-migrations`
73
-
* run `./manage.py makemigrations --replace-all --name replace_2_0 [app1, app2, ...]
73
+
* run `./manage.py makemigrations --replace-all --name replace_2_0 [app1, app2, ...]`
74
74
* commit and note the commit hash
75
75
*`git checkout [your main branch]`
76
-
* `git cherry-pick [commithash from 2-0-delete-migrations]
77
-
*`git cherry-pick [commithash from 2-0-replace-migrations]`
76
+
*`git cherry-pick [commit-hash from 2-0-delete-migrations]`
77
+
*`git cherry-pick [commit-hash from 2-0-replace-migrations]`
78
78
79
79
Now you have all migrations prior to 2.0 removed and replaced with new migrations.
80
80
@@ -84,9 +84,9 @@ That means that:
84
84
* Server database is after 2.0 -> Newly created replacement migrations will not run because all migrations they replace are already applied
85
85
* Server database is fresh -> Newly created replacement migrations will run.
86
86
87
-
## `makemigration.py`compatebility
87
+
## `makemigration.py`compatibility
88
88
89
-
This pagage 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.
89
+
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