Coverage Report - liquibase.change.core.DropForeignKeyConstraintChange
 
Classes in this File Line Coverage Branch Coverage Complexity
DropForeignKeyConstraintChange
87%
14/16
50%
2/4
1.3
 
 1  
 package liquibase.change.core;
 2  
 
 3  
 import liquibase.change.AbstractChange;
 4  
 import liquibase.change.ChangeMetaData;
 5  
 import liquibase.database.Database;
 6  
 import liquibase.database.core.SQLiteDatabase;
 7  
 import liquibase.statement.SqlStatement;
 8  
 import liquibase.statement.core.DropForeignKeyConstraintStatement;
 9  
 
 10  
 /**
 11  
  * Drops an existing foreign key constraint.
 12  
  */
 13  
 public class DropForeignKeyConstraintChange extends AbstractChange {
 14  
     private String baseTableSchemaName;
 15  
     private String baseTableName;
 16  
     private String constraintName;
 17  
 
 18  
     public DropForeignKeyConstraintChange() {
 19  16
         super("dropForeignKeyConstraint", "Drop Foreign Key Constraint", ChangeMetaData.PRIORITY_DEFAULT);
 20  16
     }
 21  
 
 22  
     public String getBaseTableSchemaName() {
 23  45
         return baseTableSchemaName;
 24  
     }
 25  
 
 26  
     public void setBaseTableSchemaName(String baseTableSchemaName) {
 27  2
         this.baseTableSchemaName = baseTableSchemaName;
 28  2
     }
 29  
 
 30  
     public String getBaseTableName() {
 31  45
         return baseTableName;
 32  
     }
 33  
 
 34  
     public void setBaseTableName(String baseTableName) {
 35  2
         this.baseTableName = baseTableName;
 36  2
     }
 37  
 
 38  
     public String getConstraintName() {
 39  46
         return constraintName;
 40  
     }
 41  
 
 42  
     public void setConstraintName(String constraintName) {
 43  2
         this.constraintName = constraintName;
 44  2
     }
 45  
 
 46  
     public SqlStatement[] generateStatements(Database database) {
 47  
 
 48  45
         if (database instanceof SQLiteDatabase) {
 49  
             // return special statements for SQLite databases
 50  0
             return generateStatementsForSQLiteDatabase(database);
 51  
         }
 52  
 
 53  45
         return new SqlStatement[] { new DropForeignKeyConstraintStatement(
 54  
                 getBaseTableSchemaName() == null ? database.getDefaultSchemaName() : getBaseTableSchemaName(),
 55  
                 getBaseTableName(), getConstraintName()), };
 56  
     }
 57  
 
 58  
     private SqlStatement[] generateStatementsForSQLiteDatabase(Database database) {
 59  
         // SQLite does not support foreign keys until now.
 60  
         // See for more information: http://www.sqlite.org/omitted.html
 61  
         // Therefore this is an empty operation...
 62  0
         return new SqlStatement[] {};
 63  
     }
 64  
 
 65  
     public String getConfirmationMessage() {
 66  1
         return "Foreign key " + getConstraintName() + " dropped";
 67  
     }
 68  
 }