Search in sources :

Example 6 with Table

use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.

the class SQLiteSchema method doEmpty.

@Override
protected boolean doEmpty() throws SQLException {
    Table[] tables = allTables();
    List<String> tableNames = new ArrayList<String>();
    for (Table table : tables) {
        String tableName = table.getName();
        if (!IGNORED_SYSTEM_TABLE_NAMES.contains(tableName)) {
            tableNames.add(tableName);
        }
    }
    return tableNames.isEmpty();
}
Also used : Table(org.flywaydb.core.internal.dbsupport.Table) ArrayList(java.util.ArrayList)

Example 7 with Table

use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.

the class H2Schema method doClean.

@Override
protected void doClean() throws SQLException {
    for (Table table : allTables()) {
        table.drop();
    }
    List<String> sequenceNames = listObjectNames("SEQUENCE", "IS_GENERATED = false");
    for (String statement : generateDropStatements("SEQUENCE", sequenceNames, "")) {
        jdbcTemplate.execute(statement);
    }
    List<String> constantNames = listObjectNames("CONSTANT", "");
    for (String statement : generateDropStatements("CONSTANT", constantNames, "")) {
        jdbcTemplate.execute(statement);
    }
    List<String> domainNames = listObjectNames("DOMAIN", "");
    if (!domainNames.isEmpty()) {
        if (name.equals(dbSupport.getCurrentSchemaName())) {
            for (String statement : generateDropStatementsForCurrentSchema("DOMAIN", domainNames, "")) {
                jdbcTemplate.execute(statement);
            }
        } else {
            LOG.error("Unable to drop DOMAIN objects in schema " + dbSupport.quote(name) + " due to H2 bug! (More info: http://code.google.com/p/h2database/issues/detail?id=306)");
        }
    }
}
Also used : Table(org.flywaydb.core.internal.dbsupport.Table)

Example 8 with Table

use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.

the class MySQLSchema method doClean.

@Override
protected void doClean() throws SQLException {
    for (String statement : cleanEvents()) {
        jdbcTemplate.execute(statement);
    }
    for (String statement : cleanRoutines()) {
        jdbcTemplate.execute(statement);
    }
    for (String statement : cleanViews()) {
        jdbcTemplate.execute(statement);
    }
    jdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 0");
    for (Table table : allTables()) {
        table.drop();
    }
    jdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 1");
}
Also used : Table(org.flywaydb.core.internal.dbsupport.Table)

Example 9 with Table

use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.

the class DB2Schema method generateDropVersioningStatement.

/**
     * @return All tables that have versioning associated with them.
     */
private List<String> generateDropVersioningStatement() throws SQLException {
    List<String> dropVersioningStatements = new ArrayList<String>();
    Table[] versioningTables = findTables("select TABNAME from SYSCAT.TABLES where TEMPORALTYPE <> 'N' and TABSCHEMA = ?", name);
    for (Table table : versioningTables) {
        dropVersioningStatements.add("ALTER TABLE " + table.toString() + " DROP VERSIONING");
    }
    return dropVersioningStatements;
}
Also used : Table(org.flywaydb.core.internal.dbsupport.Table) ArrayList(java.util.ArrayList)

Aggregations

Table (org.flywaydb.core.internal.dbsupport.Table)9 ArrayList (java.util.ArrayList)2 SQLException (java.sql.SQLException)1 FlywayException (org.flywaydb.core.api.FlywayException)1 PostgreSQLTable (org.flywaydb.core.internal.dbsupport.postgresql.PostgreSQLTable)1