1 | |
package liquibase.changelog.visitor; |
2 | |
|
3 | |
import liquibase.changelog.ChangeSet; |
4 | |
import liquibase.changelog.DatabaseChangeLog; |
5 | |
import liquibase.database.Database; |
6 | |
import liquibase.exception.LiquibaseException; |
7 | |
import liquibase.logging.LogFactory; |
8 | |
import liquibase.logging.Logger; |
9 | |
|
10 | |
public class UpdateVisitor implements ChangeSetVisitor { |
11 | |
|
12 | |
private Database database; |
13 | |
|
14 | 1 | private Logger log = LogFactory.getLogger(); |
15 | |
|
16 | 1 | public UpdateVisitor(Database database) { |
17 | 1 | this.database = database; |
18 | 1 | } |
19 | |
|
20 | |
public Direction getDirection() { |
21 | 0 | return ChangeSetVisitor.Direction.FORWARD; |
22 | |
} |
23 | |
|
24 | |
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database) |
25 | |
throws LiquibaseException { |
26 | 1 | ChangeSet.RunStatus runStatus = this.database.getRunStatus(changeSet); |
27 | 1 | log.debug("Running Changeset:" + changeSet); |
28 | 1 | ChangeSet.ExecType execType = changeSet.execute(databaseChangeLog, this.database); |
29 | 1 | if (!runStatus.equals(ChangeSet.RunStatus.NOT_RAN)) { |
30 | 0 | execType = ChangeSet.ExecType.RERAN; |
31 | |
} |
32 | |
|
33 | 1 | this.database.markChangeSetExecStatus(changeSet, execType); |
34 | |
|
35 | 1 | this.database.commit(); |
36 | 1 | } |
37 | |
} |