How to use liquibase
CREATE SNAPSHOT OF CURRENT STATE
1. Edit liquibase.properties, set the following property :
changeLogFile: 20200327.egovprod02.pidsgbt.xml driver: org.postgresql.Driver url: jdbc:postgresql://localhost:5432/pidsgbt_egovprod02 username: panasonic password: panasonic
This will target the pidsgbt_egovprod02 database in local server
2. run :
liquibase generateChangeLog
3. The snapshot will be generated in the resulting “20200327.egovprod02.pidsgbt.xml” file
CREATE DIFF BETWEEN TWO DATABASE
1. Edit liquibase.properties, set the following property :
changeLogFile: from_ref_to_target.xml driver: org.postgresql.Driver # this refers to target database, the database that we want to alter to make it the same as the reference database url: jdbc:postgresql://localhost:5432/pidsgbt_egovprod02 username: panasonic password: panasonic
# this refers to reference database referenceUrl: jdbc:postgresql://viobee.cinovasi.com:5432/egov_training referenceUsername: panasonic referencePassword: p4n450n1c3g0v
- use a descriptive name for changeLogFile to make it easy to remember, what this things is all about, e.g : from_viobee_to_pid.xml
2. run :
liquibase diffChangeLog
3. The necessary action to make the target match the reference are listed in the resulting “from_ref_to_target.xml” file
GENERATE SQL SCRIPT FOR ALTERING TARGET DATABASE
1. Edit liquibase.properties, set the following property :
changeLogFile: from_ref_to_target.xml Set the changeLogFile to the resulting file of the diffChangeLog process above
2. run :
liquibase updateSQL
3. The SQL script will be spitted in the stdout, capture it using redirection :
liquibase updateSQL > script.sql