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 | |
|
9 | |
public class RollbackVisitor implements ChangeSetVisitor { |
10 | |
|
11 | |
private Database database; |
12 | |
|
13 | 1 | public RollbackVisitor(Database database) { |
14 | 1 | this.database = database; |
15 | 1 | } |
16 | |
|
17 | |
public Direction getDirection() { |
18 | 0 | return ChangeSetVisitor.Direction.REVERSE; |
19 | |
} |
20 | |
|
21 | |
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database) |
22 | |
throws LiquibaseException { |
23 | 1 | LogFactory.getLogger().info("Rolling Back Changeset:" + changeSet); |
24 | 1 | changeSet.rollback(this.database); |
25 | 1 | this.database.removeRanStatus(changeSet); |
26 | |
|
27 | 1 | this.database.commit(); |
28 | |
|
29 | 1 | } |
30 | |
} |