Skip to content

Commit 9528337

Browse files
amilabanukamaibin
authored andcommitted
BAEL-791 Liquibase rollback (eugenp#2045)
* BAEL-791 added the sample liquibase rollback scripts * BAEL-791 Removed the auto running of migration
1 parent 4b1d021 commit 9528337

4 files changed

Lines changed: 121 additions & 0 deletions

File tree

‎liquibase/pom.xml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>parent-modules</artifactId>
7+
<groupId>com.baeldung</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>liquibase</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>mysql</groupId>
17+
<artifactId>mysql-connector-java</artifactId>
18+
<version>5.1.6</version>
19+
</dependency>
20+
</dependencies>
21+
22+
<build>
23+
<finalName>baeldung-liquibase-demo</finalName>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.apache.maven.plugins</groupId>
27+
<artifactId>maven-compiler-plugin</artifactId>
28+
<version>2.5.1</version>
29+
<configuration>
30+
<source>1.8</source>
31+
<target>1.8</target>
32+
</configuration>
33+
</plugin>
34+
35+
<plugin>
36+
<groupId>org.liquibase</groupId>
37+
<artifactId>liquibase-maven-plugin</artifactId>
38+
<version>3.4.2</version>
39+
<configuration>
40+
<propertyFile>liquibase/liquibase.properties</propertyFile>
41+
<changeLogFile>liquibase/db-changelog.xml</changeLogFile>
42+
</configuration>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
47+
</project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
4+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
5+
6+
<changeSet id="testRollback" author="baeldung">
7+
<createTable tableName="baeldung_tutorial">
8+
<column name="id" type="int"/>
9+
<column name="heading" type="varchar(36)"/>
10+
<column name="author" type="varchar(36)"/>
11+
</createTable>
12+
<rollback>
13+
<dropTable tableName="baeldung_tutorial"/>
14+
</rollback>
15+
</changeSet>
16+
17+
<changeSet id="multiStatementRollback" author="baeldung">
18+
<createTable tableName="baeldung_tutorial2">
19+
<column name="id" type="int"/>
20+
<column name="heading" type="varchar(36)"/>
21+
<column name="author" type="varchar(36)"/>
22+
</createTable>
23+
<createTable tableName="baeldung_tutorial3">
24+
<column name="id" type="int"/>
25+
<column name="heading" type="varchar(36)"/>
26+
<column name="author" type="varchar(36)"/>
27+
</createTable>
28+
<rollback>
29+
<dropTable tableName="baeldung_tutorial2"/>
30+
<dropTable tableName="baeldung_tutorial3"/>
31+
</rollback>
32+
</changeSet>
33+
34+
<changeSet id="multipleRollbackTags" author="baeldung">
35+
<createTable tableName="baeldung_tutorial4">
36+
<column name="id" type="int"/>
37+
<column name="heading" type="varchar(36)"/>
38+
<column name="author" type="varchar(36)"/>
39+
</createTable>
40+
<createTable tableName="baeldung_tutorial5">
41+
<column name="id" type="int"/>
42+
<column name="heading" type="varchar(36)"/>
43+
<column name="author" type="varchar(36)"/>
44+
</createTable>
45+
<rollback>
46+
<dropTable tableName="baeldung_tutorial4"/>
47+
</rollback>
48+
<rollback>
49+
<dropTable tableName="baeldung_tutorial5"/>
50+
</rollback>
51+
</changeSet>
52+
53+
<changeSet id="referChangeSetForRollback" author="baeldung">
54+
<dropTable tableName="baeldung_tutorial2"/>
55+
<dropTable tableName="baeldung_tutorial3"/>
56+
<rollback changeSetId="multiStatementRollback" changeSetAuthor="baeldung"/>
57+
</changeSet>
58+
59+
<changeSet id="emptyRollback" author="baeldung">
60+
<createTable tableName="baeldung_tutorial6">
61+
<column name="id" type="int"/>
62+
<column name="heading" type="varchar(36)"/>
63+
<column name="author" type="varchar(36)"/>
64+
</createTable>
65+
<rollback/>
66+
</changeSet>
67+
68+
69+
</databaseChangeLog>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
driver=com.mysql.jdbc.Driver
2+
url=jdbc:mysql://localhost:3306/baeldung_liquibase
3+
username=root
4+
password=password

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
<module>mybatis</module>
227227
<module>spring-drools</module>
228228
<module>drools</module>
229+
<module>liquibase</module>
229230
</modules>
230231

231232
<dependencies>

0 commit comments

Comments
 (0)