#34568: makemigrations --update changes the name of custom migration name
-------------------------------------+-------------------------------------
     Reporter:  David Sanders        |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Natalia Bidart):

 After reading the referenced PR and the comments in this ticket, I agree
 with David that ignoring `--name` feels like a bug, and I think it's worth
 fixing. I believe the fix would be as simple as (plus tests):

 {{{
 #!diff
 --- a/django/core/management/commands/makemigrations.py
 +++ b/django/core/management/commands/makemigrations.py
 @@ -316,7 +316,7 @@ class Command(BaseCommand):
              )
              # Update name.
              previous_migration_path =
 MigrationWriter(leaf_migration).path
 -            suggested_name = (
 +            suggested_name = self.migration_name or (
                  leaf_migration.name[:4] + "_" +
 leaf_migration.suggest_name()
              )
              if leaf_migration.name == suggested_name:
 }}}

 Regarding optimization, I would have taken a different approach in the
 original implementation: do not optimize the updated migration, leave that
 decision to the caller, they can later call `optimizemigration`. Is it too
 late for considering that approach?

 Lastly, I would not go the route of allowing to keep the current name, the
 caller can achieve that by passing `--name` which is already a documented
 and valid option for the command.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34568#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018825a6fd54-29926570-3072-4a07-8c86-3e5e47830d3a-000000%40eu-central-1.amazonses.com.

Reply via email to