Liquibase
PostgreSQL
Dev to Stg Scenario
Create properties
export DB_DEV=jdbc:postgresql://127.0.0.1:5432/project_demo_dev
export DB_STG=jdbc:postgresql://127.0.0.1:5432/project_demo_stg
Init ChangeLog from DEV
liquibase generateChangeLog \
--url=$DB_DEV
Install changelog table into source DB
liquibase update-sql \
--url=$DB_DEV
liquibase update \
--url=$DB_DEV
Preview difference btw DEV and STG
liquibase diff \
--url=$DB_STG \
--referenceUrl=$DB_DEV
Generate changelog from snapshot to STG DB
liquibase diffchangelog \
--url=$DB_STG \
--reference-url=$DB_DEV
liquibase update-sql \
--url=$DB_STG
liquibase update \
--url=$DB_STG
liquibase tag init \
--url=$DB_STG
DEV DB Schema changed...
Generate change log again
liquibase diffchangelog \
--url=$DB_STG \
--reference-url=$DB_DEV
Update STG DB
liquibase update \
--url=$DB_STG
liquibase tag release1 \
--url=$DB_STG
DEV DB Schema changed again...
liquibase diffchangelog \
--url=$DB_STG \
--reference-url=$DB_DEV
liquibase update \
--url=$DB_STG
liquibase tag release2 \
--url=$DB_STG
Rollback previous tag
liquibase rollback-sql \
--url=$DB_STG \
--tag=release1
liquibase rollback \
--url=$DB_STG \
--tag=release1
Use Snapshot
Snapshot DEV DB into snapshot.yaml
liquibase snapshot \
--url=$DB_DEV \
--snapshotFormat=yaml \
--outputFile=snapshot.yaml
Use snapshot to compare, generate change log for STG
liquibase diffchangelog \
--url=$DB_STG \
--reference-url=offline:postgresql=snapshot.yaml