[Django] #25239: Running makemigrations yields file number 0001 if the app's latest migration has a number-only filename

28 views
Skip to first unread message

Django

unread,
Aug 6, 2015, 2:36:35 PM8/6/15
to django-...@googlegroups.com
#25239: Running makemigrations yields file number 0001 if the app's latest
migration has a number-only filename
----------------------------+---------------------------------------
Reporter: zettabyte | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords: migrations makemigrations
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------
For some time we've successfully used the convention of having our
migration files only include the migration number in the filename:
{{{0001_initial.py}}}, {{{0002.py}}}, {{{0003.py}}}, etc. This currently
works with Django 1.8 with the exception of the {{{makemigrations}}}
command. When creating a new migration in this situation, it will always
give the new migration file the number {{{0001}}}.

{{{
$ ls apps/foobar/migrations/
0001_initial.py 0002.py 0003.py __init__.py
$ python manage.py makemigrations foobar
Migrations for 'foobar':
0001_widget_foobar.py:
- Add field foobar to widget
}}}

The expectation I'd have is for the newly created file to have been named
{{{0004_widget_foobar.py}}} ({{{0004}}} instead of {{{0001}}}) regarless
of the fact that {{{0003.py}}} has no "name" component. This isn't a huge
issue, since we always end up renaming the file to only include the number
anyway, but it'd be easier and less error prone if the generated number
were at least already correct.

I know that this bug is caused by the implementation of
{{{django.db.migrations.autodetector.MigrationAutoDetector.parse_number}}}
which always assumes files will be named: {{{^\d+_}}} which isn't always
the case. The rest of the migration infrastructure supports our number-
only filename convention just fine, which is why I consider this a bug
instead of a feature request.

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

Django

unread,
Aug 6, 2015, 2:39:40 PM8/6/15
to django-...@googlegroups.com
#25239: Running makemigrations yields file number 0001 if the app's latest
migration has a number-only filename
-------------------------------------+-------------------------------------

Reporter: zettabyte | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
makemigrations |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

I guess we could change the regex to end on a non-numeric character
instead.

--
Ticket URL: <https://code.djangoproject.com/ticket/25239#comment:1>

Django

unread,
Aug 8, 2015, 8:57:57 AM8/8/15
to django-...@googlegroups.com
#25239: Running makemigrations yields file number 0001 if the app's latest
migration has a number-only filename
-------------------------------------+-------------------------------------
Reporter: zettabyte | Owner:
| caioariede
Type: Bug | Status: assigned
Component: Migrations | Version: 1.8

Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
makemigrations |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by caioariede):

* owner: nobody => caioariede
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/25239#comment:2>

Django

unread,
Aug 11, 2015, 12:43:44 AM8/11/15
to django-...@googlegroups.com
#25239: Running makemigrations yields file number 0001 if the app's latest
migration has a number-only filename
-------------------------------------+-------------------------------------
Reporter: zettabyte | Owner:
| caioariede
Type: Bug | Status: assigned
Component: Migrations | Version: 1.8

Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
makemigrations |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by caioariede):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/5128

--
Ticket URL: <https://code.djangoproject.com/ticket/25239#comment:3>

Django

unread,
Aug 14, 2015, 7:29:02 AM8/14/15
to django-...@googlegroups.com
#25239: Running makemigrations yields file number 0001 if the app's latest
migration has a number-only filename
-------------------------------------+-------------------------------------
Reporter: zettabyte | Owner:
| caioariede
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: fixed

Keywords: migrations | Triage Stage: Accepted
makemigrations |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"de41fbb3cf39cf24387ba03e6a6cfb697a789a2d" de41fbb]:
{{{
#!CommitTicketReference repository=""
revision="de41fbb3cf39cf24387ba03e6a6cfb697a789a2d"
Fixed #25239 -- Corrected makemigrations numbering if a migration has a
number-only filename.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25239#comment:4>

Reply all
Reply to author
Forward
0 new messages