我想知道如果 schema 不存在,spring boot 或 Flyway 是否会创建它?
我的应用程序.属性:
spring.datasource.url=jdbc:postgresql://localhost:6432/jpa?currentSchema=jpa
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=username
spring.datasource.password=password
spring.flyway.user=username
spring.flyway.password=password
spring.flyway.schemas=jpa
spring.flyway.url=jdbc:postgresql://localhost:6432/jpa
spring.flyway.locations=classpath:db/migration
spring.main.allow-bean-definition-overriding=true
还在 build.gradle 中我有:
defaultTasks 'flywayMigrate'
谷歌没有答案。 我在第一次迁移中没有创建任何架构,只有表创建。 但是,启动后我的应用程序架构每次都会被创建。
更新:
我认为 Flyway 负责创建模式。我在调试模式下获得的日志暗示了这一点:
2023-09-06 14:05:22.121 DEBUG 22860 --- [ main] o.f.core.internal.command.DbSchemas : Creating schema: "jpa"
2023-09-06 14:05:22.122 INFO 22860 --- [ main] o.f.core.internal.database.base.Schema : Creating schema "jpa" ...
2023-09-06 14:05:22.132 INFO 22860 --- [ main] o.f.c.i.s.JdbcTableSchemaHistory : Creating Schema History table "jpa"."flyway_schema_history" ...
2023-09-06 14:05:22.133 DEBUG 22860 --- [ main] o.flywaydb.core.internal.parser.Parser : Parsing ...