Liquibase多租户:更新每个模式

huangapple go评论97阅读模式
英文:

Liquibase multi-tenancy: update every schema

问题

我为每个租户单独创建了数据库模式(也可以使用不同的数据库实例),以便能够清晰地分离他们的数据。

对于单一租户设置,使用以下容器配置:

...
  liquibase:
    image: "liquibase/liquibase:4.17.2"
    volumes:
      - ../migration:/liquibase/db/migration/
      - ./liquibase.properties:/liquibase/liquibase.properties
    command: --defaultsFile=liquibase.properties update
...

每个数据库模式都必须在每次更改日志更新时以相同的方式进行更新。

我的第一个想法是为每个模式创建尽可能多的容器(短暂存在),但是如果有很多模式(约100个),那样的扩展性不是很好。

但是是否有更好的方法?

(例如,在单个容器中执行多个模式的 liquibase CLI(多个 liquibase.properties)?在他们的文档中没有找到相关信息。)

英文:

I have separate DB schemas (could have used different DB instances) for each tenant to be able to cleanly separate their data.

For a single tenant setup the following container configuration is used:

...
  liquibase:
    image: "liquibase/liquibase:4.17.2"
    volumes:
      - ../migration:/liquibase/db/migration/
      - ./liquibase.properties:/liquibase/liquibase.properties
    command: --defaultsFile=liquibase.properties update
...

Each DB schema has to be updated the same way every time the changelog is updated.

My first idea is to create as many containers (short lived) as schemas, however that doesn't really scale that well if you have a lot of them (~100).

But is there a better way?

(eg. to execute the liquibase CLI for multiple schemas (multiple liquibase.properties?) in a single container - nothing found about that in their docs)

答案1

得分: 2

以下是已翻译的内容:

没有Liquibase CLI中处理此问题的功能。有两种选择:

  1. 创建一个自定义的Docker镜像,其中包含一个Bash脚本,可以多次调用或并行调用Liquibase CLI。

  2. 创建一个自定义的Docker镜像,其中包含自定义的Java代码,用于调用Liquibase API以一次性更新所有数据库。您可以在这里阅读有关如何创建自定义集成的更多信息 -> https://contribute.liquibase.com/extensions-integrations/integrations-overview/

英文:

There's nothing in the Liquibase CLI to handle this. There are two options to consider:

  1. Create a custom docker image that has a bash script to call out to the Liquibase CLI multiple times or even in parallel.

  2. Create a customer docker image with custom Java code to call the Liquibase APIs to update all your databases at once. You can read more about how to create custom integrations here -> https://contribute.liquibase.com/extensions-integrations/integrations-overview/

huangapple
  • 本文由 发表于 2023年5月18日 03:55:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275765.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定