01: package liquibase.database.sql;
02:
03: import liquibase.database.Database;
04: import liquibase.database.PostgresDatabase;
05: import liquibase.exception.StatementNotSupportedOnDatabaseException;
06:
07: public class DropSequenceStatement implements SqlStatement {
08:
09: private String schemaName;
10: private String sequenceName;
11:
12: public DropSequenceStatement(String schemaName, String sequenceName) {
13: this .schemaName = schemaName;
14: this .sequenceName = sequenceName;
15: }
16:
17: public String getSchemaName() {
18: return schemaName;
19: }
20:
21: public String getSequenceName() {
22: return sequenceName;
23: }
24:
25: public String getSqlStatement(Database database)
26: throws StatementNotSupportedOnDatabaseException {
27: if (!supportsDatabase(database)) {
28: throw new StatementNotSupportedOnDatabaseException(this ,
29: database);
30: }
31:
32: String sql = "DROP SEQUENCE "
33: + database.escapeSequenceName(getSchemaName(),
34: getSequenceName());
35: if (database instanceof PostgresDatabase) {
36: sql += " CASCADE";
37: }
38:
39: return sql;
40: }
41:
42: public String getEndDelimiter(Database database) {
43: return ";";
44: }
45:
46: public boolean supportsDatabase(Database database) {
47: return database.supportsSequences();
48: }
49: }
|