Liquibase: Difference between revisions
Jump to navigation
Jump to search
Line 206: | Line 206: | ||
==References== | ==References== | ||
{| | |||
| valign="top" | | |||
* [https://dba-presents.com/index.php/liquibase/46-database-independent-script-in-liquibase Database Independent Script in Liquibase] | * [https://dba-presents.com/index.php/liquibase/46-database-independent-script-in-liquibase Database Independent Script in Liquibase] | ||
* [https://stackoverflow.com/questions/49830507 Rename Liquibase changelog tables] | * [https://stackoverflow.com/questions/49830507 Rename Liquibase changelog tables] | ||
Line 216: | Line 218: | ||
* [http://www.liquibase.org/documentation/maven/generated/generateChangeLog-mojo.html#diffIncludeObjects Diff Include Objects] | * [http://www.liquibase.org/documentation/maven/generated/generateChangeLog-mojo.html#diffIncludeObjects Diff Include Objects] | ||
* [https://www.epochconverter.com Epoch Converter] | * [https://www.epochconverter.com Epoch Converter] | ||
| valign="top" | | |||
* [https://www.liquibase.org/get-started/databases Liquibase Supported Databases] | |||
|} |
Revision as of 13:29, 27 September 2020
Path Settings
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
Configuration
mkdir -p $HOME/.chorke/etc/liquibase/init
cp ./src/test/resources/liquibase/*.properties $HOME/.chorke/etc/liquibase/init
cd $HOME/.chorke/etc/liquibase/init
explorer .
Migration Commands
Command Syntax
This syntax developed by considering four types of profiles. Please find the details in Profiles. Where default
profiles are blank. Need not to mention in Maven build.
# mvn clean install -P[[[diff]database,]context,]command
# mvn clean install -P[[[dat,]mys,]dev,]log
mvn clean install -Pmys,dev,log # mysql , development
mvn clean install -Pora,pro,log # oracle, production
mvn clean install -Pdev,log # h2 , development
mvn clean install -Plog # h2 , development
Generate Change Log
# exclude data
mvn clean install -Pmys,dev,log # mysql , development
mvn clean install -Pora,pro,log # oracle, production
mvn clean install -Pdev,log # h2 , development
mvn clean install -Plog # h2 , development
|
# include data
mvn clean install -Pdat,mys,dev,log # mysql , development
mvn clean install -Pdat,ora,pro,log # oracle, production
mvn clean install -Pdat,dev,log # h2 , development
mvn clean install -Pdat,log # h2 , development
|
Differential Change Log
# exclude data
mvn clean install -Pmys,dev,dif # mysql , development
mvn clean install -Pora,pro,dif # oracle, production
mvn clean install -Pdev,dif # h2 , development
mvn clean install -Pdif # h2 , development
|
# include data
mvn clean install -Pdat,mys,dev,dif # mysql , development
mvn clean install -Pdat,ora,pro,dif # oracle, production
mvn clean install -Pdat,dev,dif # h2 , development
mvn clean install -Pdat,dif # h2 , development
|
Synchronize Change Log
mvn clean install -Pmys,dev,syn # mysql , development
mvn clean install -Pora,pro,syn # oracle, production
mvn clean install -Pdev,syn # h2 , development
mvn clean install -Psyn # h2 , development
Migrate/Update Database
mvn clean install -Pmys,dev,upd # mysql , development
mvn clean install -Pora,pro,upd # oracle, production
mvn clean install -Pdev,upd # h2 , development
mvn clean install -Pupd # h2 , development
Rollback Change Log
mvn clean install -Pmys,dev,rol -chorke.tag=20131216 # mysql , development
mvn clean install -Pora,pro,rol -chorke.tag=20131216 # oracle, production
mvn clean install -Pdev,rol -chorke.tag=20131216 # h2 , development
mvn clean install -Prol -chorke.tag=20131216 # h2 , development
Drop All/Clean Database
mvn clean install -Pmys,dev,del # mysql , development
mvn clean install -Pora,pro,del # oracle, production
mvn clean install -Pdev,del # h2 , development
mvn clean install -Pdel # h2 , development
Profiles
Four types of profiles are considerate for Maven build. Please find those profiles details are as respectively as below:
- Diff (
dat
,default
) - Database (
der
,h2d
,hsq
,mys
,ora
,pos
,default
) - Context (
dev
,qac
,uat
,pro
,default
) - Command (
log
,dif
,syn
,upd
,cle
,rol
,del
)
Where default
profiles are blank. Need not to mention in Maven build.
Diff
Porfile | Note | Diff Types |
---|---|---|
dat | Include Data | tables,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints,data |
default | Exclude Data | tables,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints |
Database
Porfile | Database | Type | JDBC | Notes |
---|---|---|---|---|
der | Apache Derby | derby | jdbc:derby | No Issues |
h2d | H2 | h2 | jdbc:h2:file | No Issues |
hsq | HSQL | hsqldb | jdbc:hsqldb:file | No Issues |
mys | MySQL | mysql | jdbc:mysql | No Issues |
ora | Oracle | oracle | jdbc:oracle:thin | 11g driver for diff with AL32UTF8 or AL16UTF16 |
pos | PostgreSQL | postgresql | jdbc:postgresql | 8.2+ for drop all database objects |
sql | Sql Server | sqlserver | jdbc:sqlserver | No Issues |
default | MySQL | mysql | jdbc:mysql | No Issues |
Context
Porfile | Context | Notes |
---|---|---|
dev | Development | Development Environment |
qac | Quality Assurance & Control | QAC Environment |
uat | User Acceptance Test | UAT Environment |
pro | Production | Production Environment |
default | Development | Development Environment |
Command
Porfile | Commands | Notes |
---|---|---|
log | generateChangeLog | Generate Change Log |
dif | diff | Generate Database Diff Change Log |
syn | changelogSync | Synchronize Database with Change Log |
upd | update | Migration/Update Database |
cle | clearCheckSums | Removes current checksums, on next run recomputed |
rol | rollback | Rollback Database to the Date/Tag |
del | dropAll | Empty/Clean Database |
Notes
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<changeSetAuthor>chorke</changeSetAuthor>
<changeSetContext>dev,qac,uat,pro</changeSetContext>
<dataDir>${project.build.directory}/${change.on}</dataDir>
<changeLogFile>META-INF/migrations/db.changelog-master.xml</changeLogFile>
<propertyFile>${user.home}/.chorke/etc/liquibase/init/${chorke.env}.properties</propertyFile>
<diffTypes>tables,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints,data</diffTypes>
<outputChangeLogFile>${project.build.directory}/db.changelog-V${version.chorke.version}_${change.on}.xml</outputChangeLogFile>
<diffIncludeObjects>table:T.*,</diffIncludeObjects>
<contexts>${chorke.ctx}</contexts>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals><goal>generateChangeLog</goal></goals>
</execution>
</executions>
</plugin>