#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.

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.78fed7f636ce55420df245d631cfa23d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to