Opened 8 years ago

Last modified 8 years ago

#27044 closed Bug

`apps` passed to post_migrate_signal should have access to migrated apps even when no migration has been applied to them — at Initial Version

Reported by: tkhyn Owned by: nobody
Component: Migrations Version: 1.10
Severity: Release blocker Keywords:
Cc: Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I noticed that when one runs migrate without arguments (implicitly migrating all apps), the apps instance passed to emit_post_migrate_signal (https://github.com/django/django/blob/1.10/django/core/management/commands/migrate.py#L221 [here]) contains the migrated apps' configurations only in the first run.

On subsequent runs, the plan list (here) is empty and post_migrate_apps is set to pre_migrate_apps (here), i.e. the unmigrated apps.

For example, when calling migrate with the contenttypes app enabled, this means that update_contenttypes (here) is passed an apps instance with contenttypes missing. The consequence is that update_contenttypes can not go further than this line.

To temporarily fix the issue and correctly trigger the post_migrate_signal so that the content types are properly updated, I need to run flush just after migrate. I don't think it should not be needed to run flush simply to correctly trigger the post_migrate_signal that will update the content types.

It worked fine in Django 1.9.9 as no project state apps instance is passed to emit_post_migrate_signal, and update_contenttypes uses the global apps instance.

I don't really know enough about the recent developments regarding apps management in Django, so I'm not sure what should be done to solve this issue. Thanks in advance if somebody has the time to look at it.

Context: I'm testing a reusable django app (django-gm2m) which test suite includes migration tests for a number of mini test apps with different models (see here). Whenever I switch to another mini-app, the database needs not only to be flushed but also re-migrated and the contenttypes need to be updated !.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top