All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.sqlgenerator.ext.DropTableGeneratorHanaDB Maven / Gradle / Ivy

The newest version!
package liquibase.sqlgenerator.ext;

import liquibase.database.Database;
import liquibase.database.core.OracleDatabase;
import liquibase.database.ext.HanaDBDatabase;
import liquibase.exception.ValidationErrors;
import liquibase.logging.LogFactory;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
import liquibase.sqlgenerator.SqlGeneratorChain;
import liquibase.sqlgenerator.core.AbstractSqlGenerator;
import liquibase.sqlgenerator.core.DropTableGenerator;
import liquibase.statement.core.DropSequenceStatement;
import liquibase.statement.core.DropTableStatement;


public class DropTableGeneratorHanaDB extends DropTableGenerator {

    @Override
    public int getPriority() {
        return PRIORITY_DATABASE;
    }

    @Override
    public boolean supports(DropTableStatement statement, Database database) {
        return database instanceof HanaDBDatabase;
    }

    public Sql[] generateSql(DropTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
        if (!supports(statement, database)) {
            return sqlGeneratorChain.generateSql(statement, database);
        }

        StringBuffer buffer = new StringBuffer();
        buffer.append("DROP TABLE ")
              .append(database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()));
        if (statement.isCascadeConstraints()) {
            buffer.append(" CASCADE");
        }
//        else {
//            buffer.append(" RESTRICT");
//        }

        return new Sql[]{
                new UnparsedSql(buffer.toString(), getAffectedTable(statement))
        };
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy