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