H2
Published 16 November 2022
H2
Supported Versions
2.0
1.4
1.3
Flyway Teams1.2
Flyway Teams
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 |
Supported versions | 1.2.137 and later |
Default Java class | org.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
/* 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