I was working on my Django command, which is a command for setting
migrations zero (link: [https://github.com/aminiun/django-
zeromigrations]).
In this command, the migration files are deleted and new migration files
are going to be generated.
The problem is, after new migrations are generated, I am trying to call
`migrate --fake` command, and during the process of loading migrations and
building graph, I found out that the old migration of some apps are
loaded, instead of new one.
After tracing the process, I found out this is because of `sys.modules`.
As the old migration files are loaded in `sys.modules` already.
In the `db/migrations/loader` module, I saw that we are reloading the
`<app>/migrations`:
{{{
# Force a reload if it's already loaded (tests need this)
if was_loaded:
reload(module)
}}}
But we are not reloading migration files modules, like
`<app>/migrations/0001_initial.py`, which was causing me error.
So I suggest to have reload for migration files too, to prevent any issues
...
--
Ticket URL: <https://code.djangoproject.com/ticket/34790>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* type: Bug => New feature
* resolution: => wontfix
Comment:
Hello,
Sorry but Django doesn't really support dynamically changing migration
files. Your feature request (and this is a feature request, not a bug) is
quite esoteric and is unlikely to be adopted. If you disagree feel free
to start a discussion on the Django forum:
https://code.djangoproject.com/wiki/DevelopersMailingList
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/34790#comment:1>