Search in sources :

Example 21 with SqlStatement

use of org.flywaydb.core.internal.dbsupport.SqlStatement in project killbill by killbill.

the class CapturingMetaDataTable method addAppliedMigration.

@Override
public void addAppliedMigration(final AppliedMigration appliedMigration) {
    final MigrationVersion version = appliedMigration.getVersion();
    final String versionStr = version == null ? null : version.toString();
    final int calculateInstalledRank;
    try {
        calculateInstalledRank = calculateInstalledRank();
    } catch (final SQLException e) {
        throw new RuntimeException(e);
    }
    final String sql = new StringBuilder().append("INSERT INTO ").append(table).append(" (").append(dbSupport.quote("installed_rank")).append(",").append(dbSupport.quote("version")).append(",").append(dbSupport.quote("description")).append(",").append(dbSupport.quote("type")).append(",").append(dbSupport.quote("script")).append(",").append(dbSupport.quote("checksum")).append(",").append(dbSupport.quote("installed_by")).append(",").append(dbSupport.quote("execution_time")).append(",").append(dbSupport.quote("success")).append(")").append(" VALUES (").append(calculateInstalledRank + appliedMigration.getInstalledRank()).append(",").append("'").append(versionStr).append("',").append("'").append(appliedMigration.getDescription()).append("',").append("'").append(appliedMigration.getType().name()).append("',").append("'").append(appliedMigration.getScript()).append("',").append(appliedMigration.getChecksum()).append(",").append(dbSupport.getCurrentUserFunction()).append(",").append(appliedMigration.getExecutionTime()).append(",").append(appliedMigration.isSuccess()).append(")").toString();
    sqlStatements.add(new SqlStatement(0, sql, false));
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) MigrationVersion(org.flywaydb.core.api.MigrationVersion) SQLException(java.sql.SQLException)

Aggregations

SqlStatement (org.flywaydb.core.internal.dbsupport.SqlStatement)21 SqlScript (org.flywaydb.core.internal.dbsupport.SqlScript)19 Test (org.junit.Test)19 ClassPathResource (org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource)11 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 FlywayWithDryRun (org.flywaydb.core.FlywayWithDryRun)1 FlywayException (org.flywaydb.core.api.FlywayException)1 MigrationVersion (org.flywaydb.core.api.MigrationVersion)1 Level (org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level)1