Opened 2 years ago

Closed 2 years ago

#23302 closed New feature (fixed)

Give a name to a migration from command line option

Reported by: Raffaele Salmaso Owned by: nobody
Component: Migrations Version: master
Severity: Normal Keywords:
Cc: raffaele.salmaso@… 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

With south, I can (or must) give a (possibly meaningful) name to a migration step

$ ./manage.py schemamigration --auto add_a_flag
$ ./manage.py schemamigration --empty my_schema_change_name

With django migrations it is impossible, it defaults to some "random" text

$ ./manage.py makemigrations myapp --empty pippo
App 'pippo' could not be found. Is it in INSTALLED_APPS?

you must change after creation

$ ./manage.py makemigrations myapp --empty
$ cd $APP/migrations
$ mv XXXX_23833_93333.py XXXX_migration.py

Attachments (1)

django-1.7-makemigrations-patch.diff (4.2 KB) - added by Raffaele Salmaso 2 years ago.
add --name/-n option to makemigrations

Download all attachments as: .zip

Change History (19)

comment:1 Changed 2 years ago by Raffaele Salmaso

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

A -n/--name option in makemigrations command could be ok

comment:2 Changed 2 years ago by Raffaele Salmaso

I've implemented --name option it against 1.7. If it is ok I'll make a proper PR against master

Changed 2 years ago by Raffaele Salmaso

add --name/-n option to makemigrations

comment:3 Changed 2 years ago by amagnus

Has patch: set

comment:4 Changed 2 years ago by amagnus

Tested --name and -n options: working properly.

comment:5 Changed 2 years ago by Raffaele Salmaso

Cc: raffaele.salmaso@… added

comment:6 Changed 2 years ago by Raffaele Salmaso

Adding tests to master/1.7.x I've found a limitation of call_command: cannot call with name="" options (see https://code.djangoproject.com/ticket/23306)
Wondering if changing option from --name/-n to --label/-l is ok.

comment:7 Changed 2 years ago by Collin Anderson

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

comment:8 Changed 2 years ago by Collin Anderson

Type: UncategorizedNew feature

comment:9 Changed 2 years ago by Raffaele Salmaso

Keep --name/-n option, works fine in master thanks to https://code.djangoproject.com/ticket/23309 and a workaround in 1.7.x backport (call makemigrations.Command().execute() directly).
I've added two PR with tests and a note in migrations doc.

PR against master https://github.com/django/django/pull/3090
PR against 1.7.x https://github.com/django/django/pull/3091

comment:10 Changed 2 years ago by Raffaele Salmaso

Summary: Cannot give a name to a migration from command lineGive a name to a migration from command line option

comment:11 Changed 2 years ago by Tim Graham

Needs documentation: unset
Needs tests: unset
Patch needs improvement: set

In my opinion this isn't a release blocking issue, so it doesn't qualify for backport to 1.7. I left some comments for improvement on the PR against master.

comment:12 Changed 2 years ago by Raffaele Salmaso

PR updates with comments.

If the 1.7 backport is too late please close its PR (I can maintain a private "fork" or continue to use mv until 1.8) and I'll add the .. versionadded:: 1.8 string.

comment:13 Changed 2 years ago by Tom Carrick

Version: 1.7-rc-2master
Last edited 2 years ago by Tom Carrick (previous) (diff)

comment:14 Changed 2 years ago by Raffaele Salmaso

PR against master updated with versionadded in docs
PR against 1.7.x dropped

comment:15 Changed 2 years ago by Raffaele Salmaso

Patch needs improvement: unset

comment:16 Changed 2 years ago by Raffaele Salmaso

PR updated with PR comments (tests, release note, docs)

comment:17 Changed 2 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:18 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 1435cfbe8dbd85c17c9a25af99f910c407dfa9bd:

Fixed #23302 -- Added --name/-n option to makemigrations command

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