[Django] #34790: loading old migration file

5 views
Skip to first unread message

Django

unread,
Aug 22, 2023, 9:19:36 AM8/22/23
to django-...@googlegroups.com
#34790: loading old migration file
----------------------------------------+------------------------
Reporter: Amin Aminian | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
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
...

--
Ticket URL: <https://code.djangoproject.com/ticket/34790>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 22, 2023, 9:49:57 AM8/22/23
to django-...@googlegroups.com
#34790: loading old migration file
------------------------------+--------------------------------------

Reporter: Amin Aminian | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: 4.2
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by David Sanders):

* 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>

Reply all
Reply to author
Forward
0 new messages