use of org.flywaydb.core.internal.dbsupport.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.dbsupport.Table in project flyway by flyway.
the class EnterpriseDBSchema method doClean.
@Override
protected void doClean() throws SQLException {
int databaseMajorVersion = jdbcTemplate.getMetaData().getDatabaseMajorVersion();
int databaseMinorVersion = jdbcTemplate.getMetaData().getDatabaseMinorVersion();
if ((databaseMajorVersion > 9) || ((databaseMajorVersion == 9) && (databaseMinorVersion >= 3))) {
// PostgreSQL 9.3 and newer only
for (String statement : generateDropStatementsForMaterializedViews()) {
jdbcTemplate.execute(statement);
}
}
for (String statement : generateDropStatementsForPackages()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForViews()) {
jdbcTemplate.execute(statement);
}
for (Table table : allTables()) {
table.drop();
}
for (String statement : generateDropStatementsForSequences()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForBaseTypes(true)) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForAggregates()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForRoutines()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForEnums()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForDomains()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForBaseTypes(false)) {
jdbcTemplate.execute(statement);
}
}
use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.
the class OracleSchema method doClean.
@Override
protected void doClean() throws SQLException {
if ("SYSTEM".equals(name.toUpperCase())) {
throw new FlywayException("Clean not supported on Oracle for user 'SYSTEM'! You should NEVER add your own objects to the SYSTEM schema!");
}
String user = dbSupport.doGetCurrentSchemaName();
boolean defaultSchemaForUser = user.equalsIgnoreCase(name);
if (!defaultSchemaForUser) {
LOG.warn("Cleaning schema " + name + " by a different user (" + user + "): " + "spatial extensions, queue tables, flashback tables and scheduled jobs will not be cleaned due to Oracle limitations");
}
for (String statement : generateDropStatementsForSpatialExtensions(defaultSchemaForUser)) {
jdbcTemplate.execute(statement);
}
if (defaultSchemaForUser) {
for (String statement : generateDropStatementsForQueueTables()) {
try {
jdbcTemplate.execute(statement);
} catch (SQLException e) {
if (e.getErrorCode() == 65040) {
//for dropping queue tables, a special grant is required:
//GRANT EXECUTE ON DBMS_AQADM TO flyway;
LOG.error("Missing required grant to clean queue tables: GRANT EXECUTE ON DBMS_AQADM");
}
throw e;
}
}
if (flashbackAvailable()) {
executeAlterStatementsForFlashbackTables();
}
}
for (String statement : generateDropStatementsForScheduledJobs()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("TRIGGER", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("SEQUENCE", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("FUNCTION", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("MATERIALIZED VIEW", "PRESERVE TABLE")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("PACKAGE", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("PROCEDURE", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("SYNONYM", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("VIEW", "CASCADE CONSTRAINTS")) {
jdbcTemplate.execute(statement);
}
for (Table table : allTables()) {
table.drop();
}
for (String statement : generateDropStatementsForXmlTables()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("CLUSTER", "")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("TYPE", "FORCE")) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForObjectType("JAVA SOURCE", "")) {
jdbcTemplate.execute(statement);
}
jdbcTemplate.execute("PURGE RECYCLEBIN");
}
use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.
the class PostgreSQLSchema method doClean.
@Override
protected void doClean() throws SQLException {
int databaseMajorVersion = jdbcTemplate.getMetaData().getDatabaseMajorVersion();
int databaseMinorVersion = jdbcTemplate.getMetaData().getDatabaseMinorVersion();
if ((databaseMajorVersion > 9) || ((databaseMajorVersion == 9) && (databaseMinorVersion >= 3))) {
// PostgreSQL 9.3 and newer only
for (String statement : generateDropStatementsForMaterializedViews()) {
jdbcTemplate.execute(statement);
}
}
for (String statement : generateDropStatementsForViews()) {
jdbcTemplate.execute(statement);
}
for (Table table : allTables()) {
table.drop();
}
for (String statement : generateDropStatementsForSequences()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForBaseTypes(true)) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForAggregates()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForRoutines()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForEnums()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForDomains()) {
jdbcTemplate.execute(statement);
}
for (String statement : generateDropStatementsForBaseTypes(false)) {
jdbcTemplate.execute(statement);
}
}
use of org.flywaydb.core.internal.dbsupport.Table in project flyway by flyway.
the class VerticaSchema method doAllTables.
@Override
protected Table[] doAllTables() throws SQLException {
List<String> tableNames = jdbcTemplate.queryForStringList(//Search for all the table names
"SELECT t.table_name FROM v_catalog.all_tables t" + //in this schema
" WHERE schema_name=?" + //Querying for 'TABLE' in Vertica will exclude views, system tables and temporary tables
" and table_type = 'TABLE'", name);
//Vertica will drop projections, when using cascade, but it will not drop views.
Table[] tables = new Table[tableNames.size()];
for (int i = 0; i < tableNames.size(); i++) {
tables[i] = new PostgreSQLTable(jdbcTemplate, dbSupport, this, tableNames.get(i));
}
return tables;
}
Aggregations