by cessor · 4y ago · 0 comments
I found that django's naming scheme for migrations is good enough; here are some real ones that I pulled out of my current project:
migrations/0006_add_modeltranslation.py
migrations/0007_remove_temp_fields.py
migrations/0008_remove_language_field.py
migrations/0009_alter_page_slug.py
migrations/0010_alter_menuitem_absolute_url.py
While they aren't semantically rich ('Why did you change absolute url on menu item?') I found that they are easy to distinguish and navigate.I much prefer the timestamp based system that is used by Rails, it make the risk of that kind of conflict a lot lower.
The migration file will contain explicit dependency information, something like:
dependencies = [
('app', '0010_alter_menuitem_absolute_url')
]
The migration engine will order the dependencies at runtime, and it will bail (and suggest creating a "merge" migration) if you have diverging trees of migrations. I find it pretty robust in practice.We have this happen at work, when merging branches; this is what `./manage.py makemigrations --merge` exists for.
That said, it's very annoying in that they're not tab-completable... any time I have to edit one, I have to stop and hunt in the entire list for what I'm looking for.