So I'm trying to run integration tests in my jhipster application, which is currently (by default, haven't made any changes to the tests config) using a H2 database. I've run mvnw clean test and I get the following error:
2018-08-09 16:05:56.340 INFO 276 --- [ main] .f.t.r.CustomAuditEventRepositoryIntTest : No active profile set, falling back to default profiles: default
2018-08-09 16:06:06.159 INFO 276 --- [ main] c.f.t.config.MetricsConfiguration : Initializing Metrics Log reporting
2018-08-09 16:06:16.258 ERROR 276 --- [ main] liquibase : classpath:config/liquibase/master.xml: config/liquibase/changelog/20180725185152_added_entity_Driver.xml::20180725185152-1::jhipster: Change Set config/liquibase/changelog/20180725185152_added_entity_Driver.xml::20180725185152-1::jhipster failed. **Error: Table "DRIVER" already exists**; SQL statement:
CREATE TABLE PUBLIC.driver (id BIGINT NOT NULL, first_name VARCHAR(255), middle_name VARCHAR(255), last_name VARCHAR(255), birth_date date, gender VARCHAR(255), suffix VARCHAR(255), weight FLOAT4, height VARCHAR(255), eye_color VARCHAR(255), hair_color VARCHAR(255), is_organ_donor BOOLEAN, drivers_license_id BIGINT, address_id BIGINT, CONSTRAINT PK_DRIVER PRIMARY KEY (id), UNIQUE (drivers_license_id)) [42101-197] [Failed SQL: CREATE TABLE PUBLIC.driver (id BIGINT NOT NULL, first_name VARCHAR(255), middle_name VARCHAR(255), last_name VARCHAR(255), birth_date date, gender VARCHAR(255), suffix VARCHAR(255), weight FLOAT4, height VARCHAR(255), eye_color VARCHAR(255), hair_color VARCHAR(255), is_organ_donor BOOLEAN, drivers_license_id BIGINT, address_id BIGINT, CONSTRAINT PK_DRIVER PRIMARY KEY (id), UNIQUE (drivers_license_id))]
So the error "Driver table already exists" makes me think
A: Liquibase is running the changesets against the db when it doesn't need to, or maybe it's running them twice?
or
B: The H2 database isn't actually getting cleaned before liquibase runs changesets.
Any ideas?
Update: Here are the properties related to hibernate and liquibase in the test directory's application.yml file:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:h2:mem:TouchQuote2Backend;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
name:
username:
password:
jpa:
database-platform: io.github.jhipster.domain.util.FixedH2Dialect
database: H2
open-in-view: false
show-sql: false
hibernate:
ddl-auto: none
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
properties:
hibernate.id.new_generator_mappings: true
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.hbm2ddl.auto: validate
liquibase:
contexts: test
I tried changing the hibernate ddl-auto property to validate and it still throws the same error.