Opened 2 years ago
Closed 2 years ago
#34790 closed New feature (wontfix)
loading old migration file
| Reported by: | Amin Aminian | Owned by: | nobody |
|---|---|---|---|
| Component: | Migrations | Version: | 4.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hi!
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 ...
Change History (1)
comment:1 by , 2 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Type: | Bug → New feature |
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!