#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a1d6681ed-9e7371d8-995b-4b4e-9ccf-ea7f4ae9322f-000000%40eu-central-1.amazonses.com.

Reply via email to