Better understanding of how Liquibase implements change sets

I want to better understand how Liquibase performs change shifts.

1)

a) For example, I have a change log with 4 sets of changes, and I run updateDatabase ( http://www.liquibase.org/documentation/ant/updatedatabase_ant_task.html ). Liquibase will make 4 sets of changes.

b) If I run the same change log again, Liquibase will not execute any set.

c) If I add a new change set to the change log and run the change log, Liquibase will only execute the new change set.

Questions:

  • How does Liquibase know which change sets are being implemented?

  • How does Liquibase know which change sets are already implemented?

2) How important is it to change the set identifier? Can I change it after executing the change log?

3) How important is the author of the changes? Can I change it after executing the change log?

4) What happens if I run rollbackDatabase ( http://www.liquibase.org/documentation/ant/rollbackdatabase_ant_task.html )? How does Liquibase know what changes are set for rollback?

a) What happens if I roll back after 1 a). Will Liquibase call a rollback item that is in every change set (4 rollback items)?

b) What happens if I roll back after 1 b). How will Liquibase know to not cause any rollback item?

c) What happens if I roll back after 1 c). Will Liquibase trigger a rollback item of only a new set of changes?

+6
source share
1 answer

I can answer a few questions, maybe not all though.

  • with. - Liquibase creates two new tables in the database on the first update. The main table is DATABASECHANGELOG, and this is used to track which change sets have been applied to the database. Liquibase uses several ways to identify each set of changes β€” the identifier, author, and path are used as the composite key. Liquibase also generates a checksum for each change set, which is used to determine if the change set was changed after being applied to the database.

  • and 3. Since the change set identifier and author are used as part of the primary key when deploying, then change one of them, you may encounter unexpected behavior in subsequent deployments. I think the identifier and the author are also part of the checksum calculation, so this can affect things as well. I would recommend that you do not change those that were after deployment.

  • Rollback uses the same mechanism to know what changes are set for rollback. When you roll back, you need to somehow indicate which changes to undo - see this page for more information: http://www.liquibase.org/documentation/rollback.html

Rollback identification mechanisms - by tag (which means you must apply tags during deployment), by date (Liquibase keeps track of when each set of changes was installed) or by number (which implicitly uses the date / time when each set of changes was deployed) .

+8
source

All Articles