55👍
✅
This works, with a minor caveat: Django will no longer know that the renamed migration is applied.
So the steps to renaming a migration are:
- Rename the file.
- Repoint any dependencies to the new file.
- If the renamed migration was already applied, apply it again using
--fake
.
If it’s a brand new migration, 2 and 3 won’t apply, and it’s perfectly fine to rename them.
👤knbk
23👍
This is happens in Django every time migrations are squashed. A new file is generated thats contains the class variable replaces
, this lists the migration files that are being replaced.
So to rename a file migration file add in the following variable in the Migration class:
replaces = [('app name', 'migration file name'), ]
And everything works like it did before the file change.
👤oden
- [Django]-Django – The included urlconf doesn't have any patterns in it
- [Django]-How to register users in Django REST framework?
- [Django]-What is the equivalent of "none" in django templates?
Source:stackexchange.com