I have 3 instances of django running on live dev/live/production. Now, due to some colleague's work I got conflicts errors due to diff branches (I have 6 branches so some have slightly diff migrations files and on pull request creating mess). Only solution which I found was resetting migrations. After that I deleted all migrations except init file . Now I am thinking to add migrations to gitignore file, as It will save further conflicts as my colleague is new and making mess.s I don't have much time to go and fix every time. So question is there any issue of doing this? Or is it harmful in near future?
Asked
Active
Viewed 164 times
0
-
May be do not merge migrations by git but use `makemigrations --merge`? if you have some migrations with `RunPython` usage - to include it by `gitignore` is bad idea. – ncopiy Jun 12 '20 at 16:17
-
@ncopiy --merge didn't solve the issue. – gamer Jun 12 '20 at 16:20
-
and why Its bad idea ? – gamer Jun 12 '20 at 16:21
-
https://stackoverflow.com/questions/28035119/should-i-be-adding-the-django-migration-files-in-the-gitignore-file/35510989 please check this question. – ytsejam Jun 12 '20 at 16:24
-
1for ex. some of your co-workers decide to update some field in a `RunPython` func. for example to replace all `-` to `_` in `username` field of `User` model. If you will not include that mirgation to your repo file you will not update all usernames in production. Also there is no info in question about building app. We have no idea hows your create a dev/prod version. We have no idea what the conflicts you had due git merge, etc. So there is no way to give you right answer without context. – ncopiy Jun 12 '20 at 16:26
-
@ncopiy If my coworker made a change in model to change username , and I will create a makemigration on production/dev , will not it reflect same on all servers ? like as I am doing changes in model and then run a migrations it sync – gamer Jun 13 '20 at 11:55
-
@gamer i tell not about model changes. Read the docs: https://docs.djangoproject.com/en/3.0/ref/migration-operations/#runpython – ncopiy Jun 13 '20 at 11:56
-
@ncopiy yes I understand there must be some cases , but I run makemigrations on server everytime if there is a model change – gamer Jun 13 '20 at 11:59
-
1@gamer anyway there is no enough information to solve your issue – ncopiy Jun 13 '20 at 12:01
1 Answers
0
So after doing and searching so much I got few points to tell.
1st : Always keep all branches up to date with migrations. after pull from github do
./manage.py makemigrations --merge
2nd: Dont delete migrations unless its so much messy . try solve by checking error in by editing customly .
3rd: keep your live server sync with migrations .Dont create separately

gamer
- 603
- 4
- 20