I was using Spring Boot 2.6.8 along with Liquibase which works fine. This is used with a MySQL database when running in production. For integration tests we run it against a H2 in memory database.
Since upgrading to SB 2.7.0, which switches out H2 v1.4.200 to v2.1.212, Liquibase then fails with the H2 in memory database.
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]:
Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for change set changelog/0.3.0/tables/file_type.xml::1437572803912-1::bobd (generated):
Reason: liquibase.exception.DatabaseException: Syntax error in SQL statement "CREATE TABLE PUBLIC.FILE_TYPE (ID INT[*](10) GENERATED BY DEFAULT AS IDENTITY NOT NULL, NAME VARCHAR(45) NOT NULL, CONSTRAINT PK_FILE_TYPE PRIMARY KEY (ID))";
expected "ARRAY, INVISIBLE, VISIBLE, NOT, NULL, AS, DEFAULT, GENERATED, ON, NOT, NULL, AUTO_INCREMENT, DEFAULT, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, COMMENT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, AUTO_INCREMENT, ,, )";
SQL statement: CREATE TABLE PUBLIC.FILE_TYPE (ID INT(10) GENERATED BY DEFAULT AS IDENTITY NOT NULL, NAME VARCHAR(45) NOT NULL, CONSTRAINT PK_FILE_TYPE PRIMARY KEY (ID)) [42001-212]
[Failed SQL: (42001) CREATE TABLE PUBLIC.FILE_TYPE (ID INT(10) GENERATED BY DEFAULT AS IDENTITY NOT NULL, NAME VARCHAR(45) NOT NULL, CONSTRAINT PK_FILE_TYPE PRIMARY KEY (ID))]
Now Liquibase should be able to map our changelog to MySQL or H2 (or any other DB) fine right? So I'm thinking this is an issue with Liquibase not support H2 v2.x properly? Or perhaps there is a property that I've missed that now needs setting?
TIA.
INT(10)
is not a valid data type for H2, H2 accepts it only in MySQL and MariaDB compatibility modes: h2database.com/html/features.html#compatibility – Fish