Flyway multiple metadata tables in one schema

前端 未结 2 1670
长发绾君心
长发绾君心 2020-12-16 19:19

I\'m trying to use Flyway to version the database of a modular application. Each module has its own separate set of tables, and migration scripts that will control the versi

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 19:40

    An ideal solution for you would be to split your modules into schemas. This gives you an effective unit of isolation per module and is also a natural fit for modular applications (modules completely isolated and self managing), rather than dumping everything into a single schema (especially public). eg

    application_database
        ├── public
        ├── module_1
        │   ├── schema_version
        │   ├── m1_t1
        │   └── m1_t2
        ├── module_2
        │   ├── schema_version
        │   ├── m2_t1
        │   └── m2_t2
        ...
    

    Your second option is to remain using the public schema to host all tables, but use an individual schema for each schema_version. This is less refactoring effort but certainly a less elegant design than that mentioned above. eg

    application_database
        ├── public
        │   ├── m1_t1
        │   ├── m1_t2
        │   ├── m2_t1
        │   └── m2_t2
        ├── module_1
        │   └── schema_version
        │
        ├── module_2
        │   └── schema_version
        ...
    

提交回复
热议问题