01: package liquibase.parser.visitor;
02:
03: import liquibase.ChangeSet;
04: import liquibase.database.Database;
05: import liquibase.exception.LiquibaseException;
06: import liquibase.log.LogFactory;
07:
08: import java.util.logging.Logger;
09:
10: public class UpdateVisitor implements ChangeSetVisitor {
11:
12: private Database database;
13:
14: private Logger log = LogFactory.getLogger();
15:
16: public UpdateVisitor(Database database) {
17: this .database = database;
18: }
19:
20: public Direction getDirection() {
21: return ChangeSetVisitor.Direction.FORWARD;
22: }
23:
24: public void visit(ChangeSet changeSet) throws LiquibaseException {
25: log.info("Running Changeset:" + changeSet);
26: changeSet.execute(database);
27: if (database.getRunStatus(changeSet).equals(
28: ChangeSet.RunStatus.NOT_RAN)) {
29: database.markChangeSetAsRan(changeSet);
30: } else {
31: database.markChangeSetAsReRan(changeSet);
32: }
33:
34: database.commit();
35: }
36: }
|