Содержимое добавляется в файлы DDL, созданные с помощью генерации сценария JPA, а не заменяется - PullRequest
0 голосов
/ 11 октября 2018

После обновления до Spring Boot 2 я заметил изменение в способе генерации файлов DDL при использовании опций: spring.jpa.properties.javax.persistence.schema-generation.scripts. *.

Ранее в Spring Boot 1.5 каждый раз, когда я запускал свое приложение или тесты (у меня также есть интеграционные тесты, проверяющие содержимое этих файлов), файлы DDL создавались заново, например:

drop table testSchema.App if exists
drop table testSchema.AppMetadata if exists
drop table testSchema.Server if exists
drop table testSchema.User if exists
drop table testSchema.UserRole if exists
drop table testSchema.UserToken if exists

Теперь, после обновления до Spring Boot 2.0.5, каждый раз, когда я запускаю свои тесты или приложение, контент добавляется в файл DDL следующим образом:

drop table testSchema.App if exists
drop table testSchema.AppMetadata if exists
drop table testSchema.Server if exists
drop table testSchema.User if exists
drop table testSchema.UserRole if exists
drop table testSchema.UserToken if exists
drop table testSchema.App if exists
drop table testSchema.AppMetadata if exists
drop table testSchema.Server if exists
drop table testSchema.User if exists
drop table testSchema.UserRole if exists
drop table testSchema.UserToken if exists
drop table testSchema.App if exists
drop table testSchema.AppMetadata if exists
drop table testSchema.Server if exists
drop table testSchema.User if exists
drop table testSchema.UserRole if exists
drop table testSchema.UserToken if exists

Не уверен, чтоэто новое поведение фреймворка или проблема с конфигурацией, которая у меня возникла только сейчас.Вот мой файл test.properties (как уже было сказано, та же проблема возникает при нормальном запуске приложения, но конфигурации относительно похожи).

# ========= DATA SOURCE : DB connection ========
spring.datasource.url=jdbc:h2:mem:myDb;INIT=CREATE SCHEMA IF NOT EXISTS testSchema
spring.datasource.username=________
spring.datasource.password=________
# ========= JPA / HIBERNATE =========
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.H2Dialect
spring.jpa.properties.hibernate.default_schema=testSchema
# DDL operations via Hibernate =========
spring.jpa.hibernate.ddl-auto = none
spring.jpa.generate-ddl = false
spring.jpa.show-sql=false
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
# DDL operations via JPA =========
spring.jpa.properties.javax.persistence.schema-generation.database.action=drop-and-create
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=drop-and-create
spring.jpa.properties.javax.persistence.schema-generation.drop-source=metadata
spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
spring.jpa.properties.javax.persistence.schema-generation.scripts.drop-target=./src/test/resources/test_data/dbCreationTestFiles/jpaGenerated_drop_test_sys_db.ddl
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=./src/test/resources/test_data/dbCreationTestFiles/jpaGenerated_create_test_sys_db.ddl

Есть ли проблема с моей конфигурацией?Как я могу настроить все так, чтобы файлы DDL перезаписывались при каждом запуске?

Спасибо.

...