01: package liquibase.database.sql;
02:
03: import liquibase.database.Database;
04: import liquibase.database.MaxDBDatabase;
05: import liquibase.database.MySQLDatabase;
06: import liquibase.exception.StatementNotSupportedOnDatabaseException;
07:
08: public class DropUniqueConstraintStatement implements SqlStatement {
09:
10: private String schemaName;
11: private String tableName;
12: private String constraintName;
13:
14: public DropUniqueConstraintStatement(String schemaName,
15: String tableName, String constraintName) {
16: this .schemaName = schemaName;
17: this .tableName = tableName;
18: this .constraintName = constraintName;
19: }
20:
21: public String getSchemaName() {
22: return schemaName;
23: }
24:
25: public String getTableName() {
26: return tableName;
27: }
28:
29: public String getConstraintName() {
30: return constraintName;
31: }
32:
33: public String getSqlStatement(Database database)
34: throws StatementNotSupportedOnDatabaseException {
35: if (database instanceof MySQLDatabase) {
36: return "ALTER TABLE "
37: + database.escapeTableName(getSchemaName(),
38: getTableName()) + " DROP KEY "
39: + getConstraintName();
40: } else if (database instanceof MaxDBDatabase) {
41: return "DROP INDEX "
42: + getConstraintName()
43: + " ON "
44: + database.escapeTableName(getSchemaName(),
45: getTableName());
46: }
47:
48: return "ALTER TABLE "
49: + database.escapeTableName(getSchemaName(),
50: getTableName()) + " DROP CONSTRAINT "
51: + getConstraintName();
52: }
53:
54: public String getEndDelimiter(Database database) {
55: return ";";
56: }
57:
58: public boolean supportsDatabase(Database database) {
59: return true;
60: }
61: }
|