Opened 8 months ago

Closed 7 months ago

#23302 closed New feature (fixed)

Give a name to a migration from command line option

Reported by: rsalmaso 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 rsalmaso 8 months ago.
add --name/-n option to makemigrations

Download all attachments as: .zip

Change History (19)

comment:1 Changed 8 months ago by rsalmaso

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 8 months ago by rsalmaso

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

Changed 8 months ago by rsalmaso

add --name/-n option to makemigrations

comment:3 Changed 8 months ago by amagnus

  • Has patch set

comment:4 Changed 8 months ago by amagnus

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

comment:5 Changed 8 months ago by rsalmaso

  • Cc raffaele.salmaso@… added

comment:6 Changed 8 months ago by rsalmaso

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 8 months ago by collinanderson

  • Needs documentation set
  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

comment:8 Changed 8 months ago by collinanderson

  • Type changed from Uncategorized to New feature

comment:9 Changed 7 months ago by rsalmaso

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 7 months ago by rsalmaso

  • Summary changed from Cannot give a name to a migration from command line to Give a name to a migration from command line option

comment:11 Changed 7 months ago by timgraham

  • 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 7 months ago by rsalmaso

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 7 months ago by knyghty

  • Version changed from 1.7-rc-2 to master
Last edited 7 months ago by knyghty (previous) (diff)

comment:14 Changed 7 months ago by rsalmaso

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

comment:15 Changed 7 months ago by rsalmaso

  • Patch needs improvement unset

comment:16 Changed 7 months ago by rsalmaso

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

comment:17 Changed 7 months ago by timgraham

  • Triage Stage changed from Accepted to Ready for checkin

comment:18 Changed 7 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 1435cfbe8dbd85c17c9a25af99f910c407dfa9bd:

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

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