H2
Published 16 November 2022
H2
- Verified Versions: 1.2, 2.0
- Maintainer: Redgate
Supported Versions and Support Levels
- For information regarding the supported version and support levels available, please see Supported Databases for Flyway
- For information regarding the Flyway features available, please see Flyway feature summary
Driver
Item | Details |
---|---|
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