如果模式不存在,什么进程会创建该模式?

问题描述 投票:0回答:1

我想知道如果 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  ...
spring postgresql spring-boot schema flyway
1个回答
0
投票

Flyway 将尝试创建

flyway.schemas
中定义的模式(如果它们不存在),并且 此行为是可配置的,可使用
createSchemas
配置参数

© www.soinside.com 2019 - 2024. All rights reserved.