BAEL-791 Liquibase rollback (#2045)
* BAEL-791 added the sample liquibase rollback scripts * BAEL-791 Removed the auto running of migration
This commit is contained in:
parent
4b1d0217e9
commit
95283376eb
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>liquibase</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>baeldung-liquibase-demo</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-maven-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<propertyFile>liquibase/liquibase.properties</propertyFile>
|
||||
<changeLogFile>liquibase/db-changelog.xml</changeLogFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,69 @@
|
|||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
|
||||
|
||||
<changeSet id="testRollback" author="baeldung">
|
||||
<createTable tableName="baeldung_tutorial">
|
||||
<column name="id" type="int"/>
|
||||
<column name="heading" type="varchar(36)"/>
|
||||
<column name="author" type="varchar(36)"/>
|
||||
</createTable>
|
||||
<rollback>
|
||||
<dropTable tableName="baeldung_tutorial"/>
|
||||
</rollback>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="multiStatementRollback" author="baeldung">
|
||||
<createTable tableName="baeldung_tutorial2">
|
||||
<column name="id" type="int"/>
|
||||
<column name="heading" type="varchar(36)"/>
|
||||
<column name="author" type="varchar(36)"/>
|
||||
</createTable>
|
||||
<createTable tableName="baeldung_tutorial3">
|
||||
<column name="id" type="int"/>
|
||||
<column name="heading" type="varchar(36)"/>
|
||||
<column name="author" type="varchar(36)"/>
|
||||
</createTable>
|
||||
<rollback>
|
||||
<dropTable tableName="baeldung_tutorial2"/>
|
||||
<dropTable tableName="baeldung_tutorial3"/>
|
||||
</rollback>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="multipleRollbackTags" author="baeldung">
|
||||
<createTable tableName="baeldung_tutorial4">
|
||||
<column name="id" type="int"/>
|
||||
<column name="heading" type="varchar(36)"/>
|
||||
<column name="author" type="varchar(36)"/>
|
||||
</createTable>
|
||||
<createTable tableName="baeldung_tutorial5">
|
||||
<column name="id" type="int"/>
|
||||
<column name="heading" type="varchar(36)"/>
|
||||
<column name="author" type="varchar(36)"/>
|
||||
</createTable>
|
||||
<rollback>
|
||||
<dropTable tableName="baeldung_tutorial4"/>
|
||||
</rollback>
|
||||
<rollback>
|
||||
<dropTable tableName="baeldung_tutorial5"/>
|
||||
</rollback>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="referChangeSetForRollback" author="baeldung">
|
||||
<dropTable tableName="baeldung_tutorial2"/>
|
||||
<dropTable tableName="baeldung_tutorial3"/>
|
||||
<rollback changeSetId="multiStatementRollback" changeSetAuthor="baeldung"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="emptyRollback" author="baeldung">
|
||||
<createTable tableName="baeldung_tutorial6">
|
||||
<column name="id" type="int"/>
|
||||
<column name="heading" type="varchar(36)"/>
|
||||
<column name="author" type="varchar(36)"/>
|
||||
</createTable>
|
||||
<rollback/>
|
||||
</changeSet>
|
||||
|
||||
|
||||
</databaseChangeLog>
|
|
@ -0,0 +1,4 @@
|
|||
driver=com.mysql.jdbc.Driver
|
||||
url=jdbc:mysql://localhost:3306/baeldung_liquibase
|
||||
username=root
|
||||
password=password
|
Loading…
Reference in New Issue