spring - 如何使用 Spring、Quarkus、Flyway、Hibernate、多租户在所有模式中运行迁移?
问题描述
早上好,我正在尝试使用 flyway、hibernate、panache 和多租户建立一个 QUARKUS 项目。但是脚本只在第一个模式上运行一次,有人知道如何在其他模式上运行吗?
应用程序.yml
datasource:
db-kind: postgres
username: postgres
password: 1234
jdbc:
url: jdbc:postgresql://localhost:5432/postgres
driver: org.postgresql.Driver
hibernate-orm:
multitenant: SCHEMA
dialect: org.hibernate.dialect.PostgreSQLDialect
log:
sql: true
flyway:
migrate-at-start: true
baseline-on-migrate: true
baseline-version: 1.0.0
create-schemas: true
clean-at-start: true
schemas: maripa, bicas, rhino
locations: db/migration/maripa, db/migration/bicas, db/migration/rhino
日志
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-03-09 07:41:54,213 INFO [io.qua.fly.FlywayProcessor] (build-13) Adding application migrations in path '/home/idd_acosta/freelas/rhino/rhino-api/target/classes/db/migration/maripa/' using protocol 'file'
2021-03-09 07:41:54,844 INFO [io.qua.arc.pro.BeanProcessor] (build-8) Found unrecommended usage of private members (use package-private instead) in application beans:
- @Inject field br.com.rhino.user.mapper.RoleMapperImpl#permissionMapper,
- @Inject field br.com.rhino.user.mapper.UserMapperImpl#roleMapper
2021-03-09 07:41:56,228 INFO [org.fly.cor.int.lic.VersionPrinter] (Quarkus Main Thread) Flyway Community Edition 7.5.2 by Redgate
2021-03-09 07:41:56,348 INFO [org.fly.cor.int.dat.bas.DatabaseType] (Quarkus Main Thread) Database: jdbc:postgresql://localhost:5432/postgres (PostgreSQL 13.1)
2021-03-09 07:41:56,380 INFO [org.fly.cor.int.com.DbClean] (Quarkus Main Thread) Successfully dropped pre-schema database level objects (execution time 00:00.001s)
2021-03-09 07:41:56,426 INFO [org.fly.cor.int.com.DbClean] (Quarkus Main Thread) Successfully dropped schema "maripa" (execution time 00:00.044s)
2021-03-09 07:41:56,428 INFO [org.fly.cor.int.com.DbClean] (Quarkus Main Thread) Successfully dropped schema " bicas" (execution time 00:00.001s)
2021-03-09 07:41:56,430 INFO [org.fly.cor.int.com.DbClean] (Quarkus Main Thread) Successfully dropped schema " rhino" (execution time 00:00.001s)
2021-03-09 07:41:56,430 INFO [org.fly.cor.int.com.DbClean] (Quarkus Main Thread) Successfully dropped post-schema database level objects (execution time 00:00.000s)
2021-03-09 07:41:56,432 INFO [org.fly.cor.int.lic.VersionPrinter] (Quarkus Main Thread) Flyway Community Edition 7.5.2 by Redgate
2021-03-09 07:41:56,437 INFO [org.fly.cor.int.dat.bas.Schema] (Quarkus Main Thread) Creating schema "maripa" ...
2021-03-09 07:41:56,439 INFO [org.fly.cor.int.dat.bas.Schema] (Quarkus Main Thread) Creating schema " bicas" ...
2021-03-09 07:41:56,439 INFO [org.fly.cor.int.dat.bas.Schema] (Quarkus Main Thread) Creating schema " rhino" ...
2021-03-09 07:41:56,443 INFO [org.fly.cor.int.sch.JdbcTableSchemaHistory] (Quarkus Main Thread) Creating Schema History table "maripa"."flyway_schema_history" ...
2021-03-09 07:41:56,487 INFO [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Current version of schema "maripa": null
2021-03-09 07:41:56,496 INFO [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Migrating schema "maripa" to version "1.0.1 - start structure maripa"
2021-03-09 07:41:56,555 INFO [org.fly.cor.int.com.DbMigrate] (Quarkus Main Thread) Successfully applied 1 migration to schema "maripa" (execution time 00:00.078
如您所见,它仅在第一个模式中运行。如何在所有三个上运行?
Obs.:对不起,我的英语!:)
解决方案
这个问题迟到了,但从Quarkus 文档看来,这是设计使然。
Flyway 的架构历史表的名称。默认情况下(单模式模式),模式历史表放置在数据源提供的连接的默认模式中。当设置 flyway.schemas 属性时(多模式模式),模式历史表被放置在列表的第一个模式中。
我想它只需要一个模式表,因为所有三个“租户”都应该保持相同的版本?
推荐阅读
- javascript - Webpack 找不到 Typescript 类型解析所需的导入。如何解决这个问题?
- swift - AVCaptureAudioDataOutput 没有调用 AVCaptureAudioDataOutputSampleBufferDelegate.captureOutput
- python - 导入 csv 文件并转换为具有特殊格式的数据框
- matlab - matlab符号数组排序问题与 equationsToMatrix 函数
- linux-kernel - 在不使用 IPC 的情况下从另一个 init 脚本向 Python 守护程序脚本发送消息
- javascript - 如何修复“错误:找不到模块'@keyv/sqlite'”错误?
- javascript - 仅使用 Material UI 中自动完成的某些部分
- node.js - node js在链中调用promise函数.then
- arm - 值如何存储在微处理器的寄存器中
- python - 这个 Python/Keras 代码的 C# 等价物是什么?