简体   繁体   中英

How do I record changes to a database in liqubase after the fact?

So I have a mysql database which is in production right now. Because it is very large changes take a long time and so for us to do things like truncate tables, add columns it takes a very long time (think several hours). Liquibase times out sometime around a half hour (doesn't matter its too short) so in order for us to make a change we need to do it manually and record the changes afterwards. We are refactoring our DB to be quite a bit smaller and adding a couple of columns but as this is in production and is constantly under load we cannot lose any of the incoming data without a large hit to both our users and ourselves. How do we record our changes in the Liquibase change log so that when it next runs it won't try to re apply our fix but it will also allow us keep the same change log for our dev environment.

As a related note we recently found out someone made a change to the prod db a few years ago and didn't record it in liquibase so is it possible to back fill a row in the change log?

To record your changes in the Liquibase tables, you use the changelogsync command. This will put rows into the DATABASECHANGELOG table corresponding to each of the changesets in the changelog.

You can do the same thing for the 'back fill' issue - create a changeset in the changelog that corresponds to the actual change made in production, and then use changelogsync to tell a particular database that the change has already been deployed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM