Opened 3 weeks ago
Closed 3 weeks ago
#36917 closed New feature (wontfix)
sqlmigrate should accept migration file path as single argument
| Reported by: | Hendrik Richter | Owned by: | |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Currently, after running makemigrations, the output shows the migration file path:
Migrations for 'invoices':
invoices/migrations/0022_alter_invoice_country_code.py
- Alter field country_code on invoice
To use sqlmigrate, I need to manually split this into two arguments:
./manage.py sqlmigrate invoices 0022_alter_invoice_country_code
It would be more convenient if sqlmigrate also accepted the path directly to make copy and pasting it easily possible:
./manage.py sqlmigrate invoices/migrations/0022_alter_invoice_country_code.py
Similarly, migrate --plan outputs a dotted format:
Planned operations:
invoices.0022_alter_invoice_country_code
- Alter field country_code on invoice
It would be convenient to use this directly as well:
./manage.py sqlmigrate invoices.0022_alter_invoice_country_code
Proposal:
Make migration_name optional. When only one argument is provided, parse app_label and migration_name from it, supporting both the path format (app/migrations/name.py) and the dotted format (app.migration_name).
Change History (2)
comment:1 by , 3 weeks ago
| Has patch: | set |
|---|
comment:2 by , 3 weeks ago
| Has patch: | unset |
|---|---|
| Resolution: | → wontfix |
| Status: | new → closed |
Thanks for the proposal. If we go this route, this will introduce drift against the
migratecommand, which also allows specifying a single migration as a target by app name & migration name. To a lesser extent this will also introduce some drift againstshowmigrations, where the first argument is always an app label and not sometimes something else. (The provided patch doesn't show the updates needed to the help text for theapp_labelargument, which would become sometimes an app label but sometimes not.)For those reasons, I don't think this is appropriate to include in Django. You can start a discussion elsewhere if you would like to gather consensus.