#26529 closed New feature (invalid)
migration: Add argument or flag which indicates the current db
Reported by: | Kadir | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.8 |
Severity: | Normal | Keywords: | migration |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
State:
Two DB's which should have all the same models.
Problem:
Running a RunPython migration on the second database fails since it still operates on the default database.
python manage.py migrate --database=seconddb
Except the hacky way, reading the sys.argv, there is no way to determine the current db to act upon that db.
Solution:
Add a parameter (or extend an existing) to include a variable "database" which contains the current db.
apps.get_model
should be able to get the schema for a specific db.
Note:
See TracTickets
for help on using tickets.
Use
schema_editor.connection.alias
to find the specified database as documented in the RunPython reference.