#34009: migrations.RunPython runs queries against wrong database
--------------------------------+--------------------------------------
Reporter: Marcel Moreaux | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution:
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 Marcel Moreaux):
* status: closed => new
* resolution: invalid =>
Comment:
Hi Alex, thanks for you feedback!
That's not how I'm reading the documentation though. What it says there is
that ''if'' you want your migrations to only run on a specific database,
you need to perform that check.
That's not what's happening here; all migrations are correctly run against
the `extra` database, ''except'' the `RunPython` migration, which is run
against `default`. The documentation you link does not imply that
`RunPython` migrations ''must'' select the database themselves, only that
they ''may'' check the selected database.
In fact, the documentation for database routers
(https://docs.djangoproject.com/en/4.1/topics/db/multi-db/#automatic-
database-routing) explicitly mentions that the Django's default database
router ensures 'stickyness' to objects' original database, which seems
violated here.
And finally, how would the migrations even set this? When running the
migrations in the context of the `default` database, the database should
be `default`, and when the migrations are run to set up the `extra`
database, the database should be `extra`. Hardcoding either database in
the migration won't work.
I maintain this is a bug, so I'm reopening this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/34009#comment:3>
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/010701833be4af24-86a7d860-730f-46de-a16e-b635cf1ddc73-000000%40eu-central-1.amazonses.com.