Opened 10 years ago

Closed 10 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: dev
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 10 years ago.
add --name/-n option to makemigrations

Download all attachments as: .zip

Change History (19)

comment:1 by Raffaele Salmaso, 10 years ago

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

comment:2 by Raffaele Salmaso, 10 years ago

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

by Raffaele Salmaso, 10 years ago

add --name/-n option to makemigrations

comment:3 by amagnus, 10 years ago

Has patch: set

comment:4 by amagnus, 10 years ago

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

comment:5 by Raffaele Salmaso, 10 years ago

Cc: raffaele.salmaso@… added

comment:6 by Raffaele Salmaso, 10 years ago

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 by Collin Anderson, 10 years ago

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

comment:8 by Collin Anderson, 10 years ago

Type: UncategorizedNew feature

comment:9 by Raffaele Salmaso, 10 years ago

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 by Raffaele Salmaso, 10 years ago

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

comment:11 by Tim Graham, 10 years ago

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 by Raffaele Salmaso, 10 years ago

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 by Tom Carrick, 10 years ago

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

comment:14 by Raffaele Salmaso, 10 years ago

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

comment:15 by Raffaele Salmaso, 10 years ago

Patch needs improvement: unset

comment:16 by Raffaele Salmaso, 10 years ago

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

comment:17 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:18 by Tim Graham <timograham@…>, 10 years ago

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