Javers错误:Postgres中已经存在关系“ jv_global_id_owner_id_fk_idx”

时间:2019-11-20 22:53:25

标签: javers

我正在尝试将Javers连接到SpringBoot应用程序,并在我的app.properties中具有以下属性:数据库是PostGres。

javers.sqlSchema=PRESENTATION_FIXTURES
javers.sqlSchemaManagementEnabled=true 
javers.commitIdGenerator=RANDOM
javers.datasource.minimum-idle=2

我的应用失败,并出现以下错误:(Schema PRESENTATION_FIXTURES是在postgres数据库中手动创建的)

2019-11-20 16:13:34.958  INFO 37952 --- [  restartedMain] o.j.r.sql.schema.JaversSchemaManager     : executing schema migration SQL:
CREATE INDEX jv_global_id_owner_id_fk_idx ON PRESENTATION_FIXTURES.jv_global_id(owner_id_fk)
2019-11-20 16:13:34.967  WARN 37952 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JaversFromStarter' defined in class path resource [org/javers/spring/boot/sql/JaversSqlAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: relation "jv_global_id_owner_id_fk_idx" already exists

我可以看到索引创建脚本试图运行两次,一次是常规创建的一部分,另一次是“模式迁移”的一部分

Create Index appearing twice

如果我在数据库中删除手动创建的架构并运行该应用程序,它将失败并显示以下信息:

Caused by: org.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:
CREATE TABLE PRESENTATION_FIXTURES.jv_commit (
commit_pk BIGINT NOT NULL,
author VARCHAR(200),
commit_date TIMESTAMP,
commit_date_instant VARCHAR(30),
commit_id NUMERIC(22,2),
CONSTRAINT jv_commit_pk PRIMARY KEY(commit_pk)
) Caused by: org.postgresql.util.PSQLException: ERROR: schema "presentation_fixtures" does not exist

我在build.gradle中使用Javers 5.8.5:

compile('org.javers:javers-spring-boot-starter-sql:5.8.5')

为什么创建索引SQL运行两次,为什么不能自动创建模式?什么是架构迁移,我可以将其关闭吗?

0 个答案:

没有答案