package com.intellisrc.db.jdbc

/**
 * @since 18/06/15.
 */
class H2Test extends JDBCTest {

    String getTableCreate(String name = "test") {
        return """CREATE TABLE $name (
                id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
                name VARCHAR(10) NOT NULL UNIQUE,
                version FLOAT,
                active BOOLEAN,
                updated DATE
        );"""
    }

    String getTableCreateMultiplePK(String name) {
        return """CREATE TABLE ${name} (
                  uid INTEGER NOT NULL,
                  gid INTEGER NOT NULL,
                  name VARCHAR(30) NOT NULL,
                  PRIMARY KEY (gid,uid)
        )"""
    }

    /**
     * Launch test:
     * docker run h2_test
     *
     * You can use the `launch_dbs_for_testing.sh` script located in /modules/db/ to launch it.
     *
     * @return
     */
    @Override
    JDBC getDB() {
        return new H2(
            dbname: File.get(File.tempDir, "h2").absolutePath,
            user: "sa",
            password: ""
        )
    }
}