Django migrations with multiple databases

前端 未结 1 1755

I have a hard time with creating data migrations. I use two databases for my apps. I configured databases in settings.py and also created a router like in Django docs.

1条回答
  •  梦毁少年i
    2020-12-25 14:21

    You have to run migrate once for each database, specifying the target with --database. Each time it will consult your router to see which migrations to actually perform on that database.

    I'm guessing it was designed this way to favor explicitness over implicitness. For example, your workflow might require you to migrate the different databases at different times.

    Note, though, that you won't be able to tell from the output which migrations were actually performed, since:

    If allow_migrate() returns False, any migration operations for the model_name will be silently skipped when running migrate on the db.

    0 讨论(0)
提交回复
热议问题