Hacker News new | ask | show | jobs
by yxhuvud 1628 days ago
My biggest objection to that naming scheme would be the numbering. If you have multiple people working on an app, it is likely that you at some point get multiples of a number as people add models simultaneously. What happens if there are multiples using a single number?

I much prefer the timestamp based system that is used by Rails, it make the risk of that kind of conflict a lot lower.

2 comments

The number-based scheme is a leftover from old times. I don't think they are actually used for ordering how the migrations are applied anymore.

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.
> My biggest objection to that naming scheme would be the numbering. If you have multiple people working on an app, it is likely that you at some point get multiples of a number as people add models simultaneously. What happens if there are multiples using a single number?

We have this happen at work, when merging branches; this is what `./manage.py makemigrations --merge` exists for.