Coverage Report - liquibase.change.core.DropTableChange
 
Classes in this File Line Coverage Branch Coverage Complexity
DropTableChange
100%
16/16
100%
4/4
1.222
 
 1  
 package liquibase.change.core;
 2  
 
 3  
 import liquibase.change.AbstractChange;
 4  
 import liquibase.change.ChangeMetaData;
 5  
 import liquibase.database.Database;
 6  
 import liquibase.statement.SqlStatement;
 7  
 import liquibase.statement.core.DropTableStatement;
 8  
 import liquibase.util.StringUtils;
 9  
 
 10  
 /**
 11  
  * Drops an existing table.
 12  
  */
 13  
 public class DropTableChange extends AbstractChange {
 14  
 
 15  
     private String schemaName;
 16  
     private String tableName;
 17  
     private Boolean cascadeConstraints;
 18  
 
 19  
     public DropTableChange() {
 20  26
         super("dropTable", "Drop Table", ChangeMetaData.PRIORITY_DEFAULT);
 21  26
     }
 22  
 
 23  
     public String getSchemaName() {
 24  49
         return schemaName;
 25  
     }
 26  
 
 27  
     public void setSchemaName(String schemaName) {
 28  11
         this.schemaName = StringUtils.trimToNull(schemaName);
 29  11
     }
 30  
 
 31  
     public String getTableName() {
 32  49
         return tableName;
 33  
     }
 34  
 
 35  
     public void setTableName(String tableName) {
 36  11
         this.tableName = tableName;
 37  11
     }
 38  
 
 39  
     public Boolean isCascadeConstraints() {
 40  48
         return cascadeConstraints;
 41  
     }
 42  
 
 43  
     public void setCascadeConstraints(Boolean cascadeConstraints) {
 44  11
         this.cascadeConstraints = cascadeConstraints;
 45  11
     }
 46  
 
 47  
     public SqlStatement[] generateStatements(Database database) {
 48  47
         boolean constraints = false;
 49  47
         if (isCascadeConstraints() != null) {
 50  1
             constraints = isCascadeConstraints();
 51  
         }
 52  
 
 53  47
         return new SqlStatement[] { new DropTableStatement(getSchemaName() == null ? database.getDefaultSchemaName()
 54  
                 : getSchemaName(), getTableName(), constraints) };
 55  
     }
 56  
 
 57  
     public String getConfirmationMessage() {
 58  1
         return "Table " + getTableName() + " dropped";
 59  
     }
 60  
 
 61  
 }