Liquibase Setup - HunYahiko/smart-parking-system GitHub Wiki
Liquibase Setup on this project.
For this project, Liquibase is used. Liquibase is a version control of the database. Every time the project is ran, the new changes are applied to it. It is also possible to apply changes via Maven plugin.
There is also a functionality for rollback included.
Another useful feature is create a changeLog for an existing database. This can save time in the beginning of the project, by generating the data via code, and then generate a changeLog file for them.
How does it work?
As it was mentioned, every change is stated in a changeLog file, in XML format. It contains SQL queries in XML format which are later converted into SQL and executed.
Liquibase actually manages just one changeLog file, which can be called a master. To apply all of our changes, we must include all changeLog files into master, so Liquibase knows where to look.
At the very first start of the project, Liquibase generates a table in our schema called databaseChangeLog which saves all the executed changeLog files, along with the authors, execution date and time, a md5sum etc. By having this table, Liquibase will not execute changeLog files which were already executed on the next run.
Project setup
To find the liquibase setup, you can take a look at ..sps-backend\src\main\resources\liquibase\liquibase.properties file.
The master file can be found at ..sps-backend\src\main\resources\liquibase folder. It includes some of the changeLog files defined in the system.
To add a new changeLog however, the file must be added to ..sps-backend\src\main\resources\liquibase\migrations folder. All of the files are included there. To actually execute it, we must add it to master file. On the first run, all of the changeLog files will be executed, creating all the tables and data which should exist for the project to function.