Paul Stanley
Paul Stanley

Reputation: 4098

liquibase generate sql between 2 changelogs

We currently use liquibase to version control our mysql database, however, we are not allowed to run liquibase on production. The first time we deployed we did an sql dump of the database, which was the amalgamation of all the changelogs to date.

So say the changelog currently is at changelog 128 on production. How do I generate the sql of changelogs from 128 to 140 in liquibase?

Upvotes: 0

Views: 1326

Answers (1)

Jens
Jens

Reputation: 6383

You can use updateSQL to output the changes to a SQL delta script file instead of the database directly.

Could work like this: You keep a copy of the production database (just the structure - no data needed) as a reference DB. You let all the 128 changeset run on that db, so that it is at the same state as the production DB.

Then let liquibase run against that database with updateSQL. This will only output the missing SQLs (from 128 to 140) in a file. Then you have delta SQL Script.

Assuming in production you have 1.0 and the next release is 1.1 and changesets 128-140 are part of goind from 1.0 to 1.1 then you could name the file sql_delta__1_0_to_1_1.sql.

DB Admins can inspect the delta file and if they think it's ok, they can let it run and your prod db will be on version 1.1.

After that you also run the delta script to your reference db to make sure it is at the same state as you prod db.

And for the next version you repeat the whole thing. I guess you get the concept.

That's how we use it...

Upvotes: 1

Related Questions