Managing database snapshots with liquibase

I’m dealing with following scenario:

I have two types of databases with different purposes: demo and dev. I’m maintaining the changelog file with all DDL changes and some technical data changes (My application stores some configuration data in the db). I also want to store somewhere my demo data. So ideally it could be obtained by storing all the db changes in the changelog (with different contexts) BUT: the data in the demo instance are inserted via application, not only by developers but also others people from the project. Additionally the db schema is quite large and inserting one entity results with inserting records in several different tables. Therefore managing such changelog for the demo data is very difficult and time consuming.

So I want to be able to make a full demo database snapshot on demand and store it in the project to be not dependent of external db instance.

Can liquibase help me in such case?

I’ve considered the following solutions:

  1. Maintaining DDL's in changelog file and all the data in demo.snapshot file with 'demo' contexts. So if I want to create new demo instance on empty db I can run first the ddl's and then load the demo data. But I dismiss this solution because it works only when the snapshot is done from the newest db schema. If I take a snapshot of demo and then I add some DDL's I will not be able to insert old data on new db schema.
  2. Maintaining all DB changes (DDL's + technical data, not including demo data) in changelog and store dump of whole demo db (including DDL's). So if I want to create new demo instance on empty db I will run the dump file and liquibase:update command. Disadvantage of this solution is that I must use external tool to generate such snapshot (or liquibase can help? I tried with generateChangeLog command but it omits the DATABASECHANGELOG table so the liquibase:update command will crash)

Have you dealed with such case and found solution? I’ll be thankful for any advice.

Additional constraints:

  • I started with existing database but I solved it by creating the 'initial' context with the initial state.
  • As I mentioned I want to be able to create the dev db instance with only technical data included