#24086: No pre_migrate signal is emitted if rolling back the migration history
---------------------------------+--------------------------------
Reporter: andrewhayes1979 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords: pre_migrate signal
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------
Use case:
Suppose I have an app "myapp" with a model "MyModel", run makemigrations
to generate 0001 and then migrate:
- I'll get both the pre_migrate and post_migrate signals fired when
running the migration
If I then add a field to MyModel, run makemigrations to generate 0002 and
then migrate:
- I'll also get both the pre_migrate and post_migrate signals fired.
(this was addressed in this ticket:
https://code.djangoproject.com/ticket/23975)
If I now run "python manage.py migrate myapp 0001" to rollback the 0002
migration, I'll only get a post_migrate signal emitted, '''no
pre_migrate'''.
The sync_apps() function that the pre_migrate signal emit code lives in is
never called in this use case.
Desired behaviour:
- '''all''' calls to migrate should generate pre_migrate and post_migrate
signals to bookend the start/end of database schema modifications
...the documentation for the pre_migrate signal currently states that it
is fired only when installing an app, however the fix for
https://code.djangoproject.com/ticket/23975 means this is no longer
accurate.
...simply firing the 2 events anytime a database schema migration occurs
(forwards or backwards) would be simpler and easier to understand, IMO
Also, as an aside, it would be nice if richer information were provided in
the post_migrate signal in terms of a list of model-classes that were
modified for e.g. I'm currently relying on database introspection in
pre_migrate and post_migrate signal-handlers to watch for changes in
model-schemas...since the migration-functionality knows what it has/hasn't
run, it'd be nice if this information were shared out in the post_migrate
signal perhaps?
--
Ticket URL: <https://code.djangoproject.com/ticket/24086>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/058.f3b9c3a3942c25d34470c2691465be37%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.