Once you have Liquibase going, this is the General Workflow.
A requirement comes in for a database change
Make a change to the Liquibase files
- Create a new branch, switch to that branch.
SQL
Usually there’s one transation file per database. Locate this file and open it.
Make changes to the file. For example…
1 | -- changeset Mark:48378-09 |
In this case you need a comment above each sql command. “– changeset xxx:yyy” the combination of xxx:yyy must be unique and once liquibase proceses this it can never be changed - so be careful. but later you can add commands to undo the effect of that command.
Typically I use xxx = my name, yyy is broken into a task number, and a change for that task number. For example 48378-09 means task 48378, change 09.
XML
If you are using XML based liquibase files, then you need to add a new entry to the file.
1 | <changeSet author="MarkWachdorf" id="63162-addColumn-3"> |
In this case I am adding a couple of columns to the DbColumn database.
Execute Liquibase
1 | liquibase update |
or
1 | liquibase updateSQL --changelog-file=dd_changelog.xml |
Will scan the files and execute the changesets that have not yet been executed. If you have a change that has already been executed, then liquibase will not execute it again. If you get an error, then you need to fix the error and execute the command again.