Search in sources :

Example 1 with FlywayWithDryRun

use of org.flywaydb.core.FlywayWithDryRun in project killbill by killbill.

the class Migrator method main.

/**
     * Main method.
     *
     * @param args The command-line arguments.
     */
public static void main(final String[] args) {
    final Level logLevel = getLogLevel(args);
    initLogging(logLevel);
    try {
        if (isPrintVersionAndExit(args)) {
            printVersion();
            System.exit(0);
        }
        final List<String> operations = determineOperations(args);
        if (operations.isEmpty()) {
            printUsage();
            return;
        }
        final Properties properties = new Properties();
        initializeDefaults(properties);
        loadConfiguration(properties, args);
        overrideConfiguration(properties, args);
        dumpConfiguration(properties);
        loadJdbcDrivers();
        loadJavaMigrationsFromJarDirs(properties);
        final List<SqlStatement> sqlStatements = new LinkedList<SqlStatement>();
        final FlywayWithDryRun flyway = new FlywayWithDryRun(sqlStatements);
        filterProperties(properties);
        flyway.configure(properties);
        for (final String operation : operations) {
            executeOperation(flyway, operation, sqlStatements);
        }
    } catch (final Exception e) {
        if (logLevel == Level.DEBUG) {
            LOG.error("Unexpected error", e);
        } else {
            if (e instanceof FlywayException) {
                LOG.error(e.getMessage());
            } else {
                LOG.error(e.toString());
            }
        }
        System.exit(1);
    }
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) FlywayException(org.flywaydb.core.api.FlywayException) FlywayWithDryRun(org.flywaydb.core.FlywayWithDryRun) Level(org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level) Properties(java.util.Properties) LinkedList(java.util.LinkedList) FlywayException(org.flywaydb.core.api.FlywayException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 FlywayWithDryRun (org.flywaydb.core.FlywayWithDryRun)1 FlywayException (org.flywaydb.core.api.FlywayException)1 SqlStatement (org.flywaydb.core.internal.dbsupport.SqlStatement)1 Level (org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level)1