k4br4s
k4br4s

Reputation: 167

Generate changelog between a snapshot and a database

In order to track changes for a database I thought that the best solution is to generate a snapshot of the database, make the changes and the get a changelog comparing the snapshot with the db.

For the snapshot I use the following command:

 $ liquibase --url=jdbc:postgresql://localhost:5432/test 
 outputFile=sdk/workspace//output.json --snapShotFormat=json

Now that I have the snapshot, I made some changes in the database (adding 2 columns to 2 different tables). I try to run to following command to compare the snapshot with the db:

 $ liquibase --url=jdbc:postgresql://localhost:5432/test - 
 username=postgres --password=new_password -- 
 referenceUrl=offline:postgresql?snapshot=sdk/testsnapshot.json 
 diffchangelog

but I get the following error:

 $ Unexpected error running Liquibase: Cannot parse snapshot 
 offline:postgresql?snapshot=sdk/testsnapshot.json

Any idea on how to fix this?

Upvotes: 5

Views: 1516

Answers (1)

k4br4s
k4br4s

Reputation: 167

I manage to solve the problem and in case that someone will have the same issue in the future, this is the correct way to do it.

Generate the snapshot:

liquibase 
--driver=org.postgresql.Driver \
--classpath=lib/postgresql42.2.5.jre6.jar \ 
--url=jdbc:postgresql://localhost:5432/test \
--outputFile=sdk/snaptest.json \
--username=postgres \
--password=new_password \
snapshot 

Generate the diffChangeLog between the snapshot and the database

liquibase 
--driver=org.postgresql.Driver \
--changeLogFile=sdk/workspace/difference_log.xml \
--url=jdbc:postgresql://localhost:5432/test \
--username=postgres \
--password=new_password \
--referenceUrl=offline:postgresql=sdk/snaptest.json \
diffchangelog

Cheers

Upvotes: 8

Related Questions