Spring Boot and MySQL here. Trying to get my Spring Boot app to use Liquibase for my DB migrations and see in the docs that Spring Boot has built-in support for Liquibase.
However after reading those docs, I'm left with several related concerns:
db/changelog/db.changelog-master.yaml
file? Is it to store Liquibase configurations (that dictate how Liquibase behaves), or is that where I'm supposed to put the actual, sequential SQL changes (the "migrations") themselves?
src/main/resources/migrations
directory and store my migration changes as individual SQL files, like so:src/main/resources/migrations/001-schema.sql
src/main/resources/migrations/002-init.sql
src/main/resources/migrations/003-changing-account-types.sql
The db/changelog/db.changelog-master.yaml
file is the one executed on application startup when using default configuration. In that file you can have the sequential SQL changes as well as inclusions to other files. For example the file could contain inclusions like this (xml syntax)
<include file="migrations/001-schema.sql"/>
<include file="migrations/002-init.sql"/>
<include file="migrations/003-changing-account-types.sql"/>
and you would have the configuration you wanted.
About your second question - yes, they are applied at startup. If it runs on a cluster of nodes, they will each check the status and apply the changes to database if they aren't already applied(the databasechangelog and databasechangelock tables are used for that and they make sure the changes are only applied once)
example for yaml syntax
databaseChangeLog:
- include:
file: migrations/001-schema.sql
- include:
file: migrations/002-init.sql
- include:
file: migrations/003-changing-account-types.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With