My package structure is looks like:
In /db.changelog/db.changelod-master.xml i include /db.changelog/v1/db.changelog-1.0.xml where i also include all changelogs from /db.changelog/v1/changeset package.
In my application, I have two profiles: dev and prod, and I need to divide the structure of packages according to "Best Practises" of Liquibase. Some changelogs can be in prod and dev environment.
Also, I can use context attribute in changeset tag and explicitly set dev or prod value, but this workaround is not preferable.
Simple usage looks like: i switch to prod profile and some tables will not be created or some inserts to Database will be skipped.
Can you please help me refactor structure of packages according to Liquibase "Best Practices??
Solution1:
You need to define 'liquibase.contexts' property into your yaml file. Something like below.
After adding this the below change set will only execute when your local profile is 'dev' (i.e. spring-boot:run -Dspring.profiles.active=dev)
Solution2:
If you don't want to use liquibase.context, You might can use maven to filter recourses : The key was to use the maven filter element in conjunction with the resource element as explained in Liquibase Documentation.
Also it's important to include the resources goal in the maven command:
This is the file hierarchy I used:
The db.properties file would look like the following:
The liquibase.properties file would look like the following:
The POM file would look like the following: