How to use Liquibase diffChangeLog with the current list of changes as a reference (to create an incremental set of changes)

I have an existing database and I used the generateChangeLog command to create the original change log. This works great :-)

But now I want developers to use all the tools / processes that they already know / use to develop the database and code, and use the script to generate any incremental changesets as needed.

That is: make the difference with the current state of the developer database (url / username / password in the properties file) using the current change log (changeLogFile in the properties file) as the base link.

There seems to be no easy way to do this - the best I came up with is:

  • Create a new temporary database.
  • Use Liquibase to initialize the temp database (to what is currently on the change list) by overriding the connection URL: liquibase --url=jdbc:mysql://localhost:3306/tempbase update
  • Use Liquibase to create a change set in the change log using two databases: liquibase --referenceUrl=jdbc:mysql://localhost:3306/tempbase --referenceUsername=foo --referencePassword=baz diffChangeLog
  • Delete the temporary database.
  • Sync change set: liquibase changelogSync

but there must be a better way ...

+6
source share
1 answer

You are correct that Liquibase cannot compare the change file with the database. The only real option is to compare your developer database with the actual fluid-controlled database, or at least one temporarily created one.

What I would like to suggest as the best way is to consider migrating developers to LiquibaseSetets shifts first. These are different tools than they can be used, but they have a huge advantage that they will know that the change they wanted to make is the one that will do everything possible to produce it. Any diff-based process (for example, using diffChangeLog), as a rule, correctly guesses what has changed, but not always, and these differences are often not noticed before production.

Liquibase has various functions, such as formatted SQL versions of changes, which are designed to move from developers working directly to their database to track changes through Liquibase because, as soon as this transition is done, many things become much easier.

0
source

Source: https://habr.com/ru/post/970203/


All Articles