use of org.flywaydb.core.internal.database.base.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<>();
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;
}
use of org.flywaydb.core.internal.database.base.Table in project flyway by flyway.
the class DerbySchema method doClean.
@Override
protected void doClean() throws SQLException {
List<String> triggerNames = listObjectNames("TRIGGER", "");
for (String statement : generateDropStatements("TRIGGER", triggerNames, "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForConstraints()) {
jdbcTemplate.execute(statement);
}
List<String> viewNames = listObjectNames("TABLE", "TABLETYPE='V'");
for (String statement : generateDropStatements("VIEW", viewNames, "")) {
jdbcTemplate.execute(statement);
}
for (Table table : allTables()) {
table.drop();
}
List<String> sequenceNames = listObjectNames("SEQUENCE", "");
for (String statement : generateDropStatements("SEQUENCE", sequenceNames, "RESTRICT")) {
jdbcTemplate.execute(statement);
}
}
use of org.flywaydb.core.internal.database.base.Table in project flyway by flyway.
the class SQLiteSchema method doClean.
@Override
protected void doClean() throws SQLException {
foreignKeysEnabled = jdbcTemplate.queryForBoolean("PRAGMA foreign_keys");
List<String> viewNames = jdbcTemplate.queryForStringList("SELECT tbl_name FROM " + database.quote(name) + ".sqlite_master WHERE type='view'");
for (String viewName : viewNames) {
jdbcTemplate.execute("DROP VIEW " + database.quote(name, viewName));
}
for (Table table : allTables()) {
table.drop();
}
if (getTable(SQLiteTable.SQLITE_SEQUENCE).exists()) {
jdbcTemplate.execute("DELETE FROM " + SQLiteTable.SQLITE_SEQUENCE);
}
}
use of org.flywaydb.core.internal.database.base.Table in project flyway by flyway.
the class MySQLSchema method doClean.
@Override
protected void doClean() throws SQLException {
if (database.eventSchedulerQueryable) {
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");
// MariaDB 10.3 and newer only
for (String statement : cleanSequences()) {
jdbcTemplate.execute(statement);
}
}
use of org.flywaydb.core.internal.database.base.Table in project flyway by flyway.
the class IgniteThinSchema 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> aliasNames = jdbcTemplate.queryForStringList("SELECT ALIAS_NAME FROM INFORMATION_SCHEMA.FUNCTION_ALIASES WHERE ALIAS_SCHEMA = ?", name);
for (String statement : generateDropStatements("ALIAS", aliasNames)) {
jdbcTemplate.execute(statement);
}
List<String> domainNames = listObjectNames("DOMAIN", "");
if (!domainNames.isEmpty()) {
if (name.equals(database.getMainConnection().getCurrentSchema().getName())) {
for (String statement : generateDropStatementsForCurrentSchema("DOMAIN", domainNames)) {
jdbcTemplate.execute(statement);
}
} else {
LOG.error("Unable to drop DOMAIN objects in schema " + database.quote(name));
}
}
}
Aggregations