liquibase在2个changelog之间生成sql [英] liquibase generate sql between 2 changelogs

查看:238
本文介绍了liquibase在2个changelog之间生成sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前使用liquibase对我们的mysql数据库进行版本控制,但是,我们不允许在生产环境中运行liquibase.第一次部署时,我们对数据库进行了sql转储,这是迄今为止所有变更日志的合并.

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.

所以说变更日志当前在生产中的变更日志128上. 如何在liquibase中生成从128到140的变更日志的SQL?

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?

推荐答案

您可以使用 updateSQL 将更改输出到SQL增量脚本文件而不是直接输出到数据库.

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

可以这样工作: 您可以保留生产数据库的副本(仅保留结构-无需数据)作为参考数据库. 您让所有128个changeset都在该db上运行,以便它与生产DB处于相同的状态.

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.

然后使用 updateSQL 使liquibase针对该数据库运行.这只会在文件中输出缺少的SQL(从128到140). 然后,您将获得增量SQL脚本.

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.

假设在生产环境中有1.0,下一个发行版是1.1,变更集128-140是goind从1.0到1.1的一部分,则可以将文件命名为sql_delta__1_0_to_1_1.sql.

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.

数据库管理员可以检查增量文件,如果他们认为还可以,则可以让它运行,您的产品数据库将为1.1版.

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.

在那之后,您还要对参考数据库运行delta脚本,以确保它与您的生产数据库处于相同的状态.

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...

这篇关于liquibase在2个changelog之间生成sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆