Back to Flyway

H2

documentation/Reference/Database Driver Reference/H2.md

latest1.8 KB
Original Source
  • Verified Versions: 1.2, 2.0
  • Maintainer: {% include redgate-badge.html %}

Supported Versions and Support Levels

{% include database-boilerplate.html %}

Driver

ItemDetails
URL format<code>jdbc:h2:<i>file</i></code>
Ships with Flyway Command-lineYes
Maven Central coordinatescom.h2database:h2
Supported versions1.2.137 and later
Default Java classorg.h2.Driver

SQL Script Syntax

  • Standard SQL syntax with statement delimiter ;
  • $$ delimited strings

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

sql
/* 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'$$);

Known Vulnerabilities

H2 has a known RCE vulnerability that is unlikely to be fixed as it isn't enabled by default, and it is not exploitable in Flyway's use of H2.

We will update our CLI to the fixed version as soon as it becomes available, but if this is a concern you can remove the H2 dependency if you do not require it by deleting the h2-<version> JAR from the drivers folder

Limitations

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