#31769: Improve default name of merge migrations.
-------------------------------------+-------------------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Migrations | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* resolution: => wontfix
Comment:
I'm not sure about this change because you may need to merge many
migrations. In such case it seems that the timestamp is the best we can
do, e.g. (with your patch):
{{{
$ python manage.py migrate
CommandError: Conflicting migrations detected; multiple leaf nodes in the
migration graph: (0002_mymodel1_field_1,
0002_mymodel10_mymodel2_mymodel3_mymodel4_mymodel5_mymodel6_mymodel7_mymodel8_mymodel9,
0002_mymodel101_mymodel21_mymodel31_mymodel41_mymodel51_mymodel61_mymodel71_mymodel81_mymodel91
in test_one).
To fix them run 'python manage.py makemigrations --merge'
$ python manage.py makemigrations --merge
Merging test_one
Branch
0002_mymodel10_mymodel2_mymodel3_mymodel4_mymodel5_mymodel6_mymodel7_mymodel8_mymodel9
- Create model MyModel1
- Create model ...
Branch 0002_mymodel1_field_1
- Add field field_1 to mymodel1
Branch
0002_mymodel101_mymodel21_mymodel31_mymodel41_mymodel51_mymodel61_mymodel71_mymodel81_mymodel91
- Create model MyModel101
- Create model ...
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Do you want to merge these migration branches? [y/N] y
Traceback (most recent call last):
....
res = handle_func(*args, **kwargs)
File "/django/django/core/management/commands/makemigrations.py", line
140, in handle
return self.handle_merge(loader, conflicts)
File "/django/django/core/management/commands/makemigrations.py", line
309, in handle_merge
with open(writer.path, "w", encoding='utf-8') as fh:
OSError: [Errno 36] File name too long:
'/ticket_31769/test_one/migrations/0003_merge_0002_mymodel101_mymodel21_mymodel31_mymodel41_mymodel51_mymodel61_mymodel71_mymodel81_mymodel91_0002_mymodel10_mymodel2_mymodel3_mymodel4_mymodel5_mymodel6_mymodel7_mymodel8_mymodel9_0002_mymodel1_field_1.py'
}}}
Truncating merged names will be even more confusing.
You always use the `--name` option if you don't like a generated name
(maybe we could ask for it in the `interactive` mode 🤔).
--
Ticket URL: <https://code.djangoproject.com/ticket/31769#comment:2>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.056fabe3425314216a93480065d56206%40djangoproject.com.