01: package liquibase.preconditions;
02:
03: import liquibase.DatabaseChangeLog;
04: import liquibase.database.Database;
05: import liquibase.exception.PreconditionFailedException;
06:
07: /**
08: * Precondition for specifying the type of database (oracle, mysql, etc.).
09: */
10:
11: public class DBMSPrecondition implements Precondition {
12: private String type;
13:
14: public DBMSPrecondition() {
15: }
16:
17: public String getType() {
18: return type;
19: }
20:
21: public void setType(String atype) {
22: this .type = atype.toLowerCase();
23: }
24:
25: public void check(Database database, DatabaseChangeLog changeLog)
26: throws PreconditionFailedException {
27: String dbType = database.getTypeName();
28: if (!type.equals(dbType)) {
29: throw new PreconditionFailedException(
30: "DBMS Precondition failed: expected " + type
31: + ", got " + dbType, changeLog, this );
32: }
33: }
34:
35: public String getTagName() {
36: return "dbms";
37: }
38:
39: }
|