Opened 9 years ago
Closed 9 years ago
#25239 closed Bug (fixed)
Running makemigrations yields file number 0001 if the app's latest migration has a number-only filename
Reported by: | Kendall Gifford | Owned by: | Caio Ariede |
---|---|---|---|
Component: | Migrations | Version: | 1.8 |
Severity: | Normal | Keywords: | migrations makemigrations |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (4)
comment:1 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I guess we could change the regex to end on a non-numeric character instead.