Django 1.8 Migration with Postgres BDR 9.4.1

微笑、不失礼 提交于 2019-12-05 13:13:35

In order to use migrations with BDR, you would need to create your migrations by hand, using only "safe" operations, because BDR is not currently able to replicate operations such as the one in your migration.

In an email conversation I had recently with support at 2nd Quadrant (the primary sponsors of BDR development), I was given this information on the topic:

There is no timeline in delivering this. It's very hard to accomplish.

You can still alter a column's type, it just takes multiple steps. In general, you do DDL in BDR as if you were doing it with a lock-avoidance approach in stock PostgreSQL. So in this case you:

  • ADD the new column without a DEFAULT and without any NOT NULL, and commit. If needed, also create a trigger to automatically fill the new column when values are inserted. Or ALTER the new column to set a DEFAULT, if that's more appropriate.
  • UPDATE the table to copy values to the new column with new type
  • ALTER the table to make it NOT NULL if appropriate
  • DROP the old column

I also found this article from BrainTree to be a great reference for what could be considered "safe" operations, and how you would have to rewrite the behavior in your migrations.

You can override built-in migrations for auth app using the MIGRATION_MODULES setting, for example:

MIGRATION_MODULES = {
    'auth': 'bdr_migrations.auth',
}

Then copy migration files from django package to /project/bdr_migrations/auth/ and adjust them to match BDR restrictions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!