New! – Spin up instant copies of your dev databases in the cloud for free Learn more

Flyway Documentation

Poll

H2

Supported Versions

Support Level

Compatible
Certified
Guaranteed Flyway Teams

Support Level determines the degree of support available for this database (learn more).

Driver

URL format jdbc:h2:file
Ships with Flyway Command-line Yes
Maven Central coordinates com.h2database:h2:1.4.200
Supported versions 1.2.137 and later
Default Java class org.h2.Driver

SQL Script Syntax

Compatibility

  • DDL exported by H2 can be used unchanged in a Flyway migration
  • Any H2 SQL script executed by Flyway, can be executed by the h2 tools (after the placeholders have been replaced)

Example

/* Single line comment */
CREATE TABLE test_data (
 value VARCHAR(25) NOT NULL PRIMARY KEY
);

/*
Multi-line
comment
*/

-- Sql-style comment

-- Placeholder
INSERT INTO ${tableName} (name) VALUES ('Mr. T');
INSERT INTO test_user (name) VALUES ( $$'Mr. Semicolon+Linebreak;
another line'$$);

Limitations

  • Due to H2 limitations DOMAIN objects can only be cleaned in the current schema

HSQLDB