在现有数据库上使用liquibase [英] Using liquibase on the existing database

查看:249
本文介绍了在现有数据库上使用liquibase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个生产中的现有数据库。我们已决定使用liquibase进行所有进一步的更新,并创建任何新数据库(例如开发或集成)。

We have a existing database in production. We have decided to use liquibase for all further updates and create any new database (like development or integration).

我们已经基于现有的生产模式创建了liquibase脚本(以创建任何新的数据库,如开发,集成等)。在该脚本之上,我们还添加了两个更新。继续对生产数据库进行所有进一步的更新将由liquibase完成。

We have created liquibase scripts based on the existing production schema (to create any new database like development, integration, etc). On top of that script we have also added two more updates. Going forward all further updates to production DB will be done by liquibase.

如果我们在生产中执行liquibase,它将尝试进行所有完整的更改,即使是已经进行的更改存在,这应该不会发生,因为生产已经拥有除了两个新更新之外的所有内容。现在,我们要使用liquibase单独将这两个更改更新到生产中。

If we execute the liquibase on production, it will try do all the complete changes even those which are already exist, which should not happen as production already has everything except the two new updates. Now we want to use the liquibase to update those two changes alone to productions.

我们该怎么做?

推荐答案

放置过程在liquibase控制下的现有数据库如下:

The process to put a existing database under liquibase control is the following:


  1. 创建初始变更日志(这就是您所做的事情)

  2. 使用命令 changelogSync 运行liquibase。这将创建Liquibase表并将所有更改集标记为已应用(这是您错过的内容)

  3. 添加更改集

  4. 使用以下命令运行liquibase命令 update 应用更改集。

  1. Create the initial changelog (that's what you did)
  2. Run liquibase using the command changelogSync. This will create the Liquibase tables and mark all change sets as being applied (this is what you missed)
  3. Add your change sets
  4. Run liquibase using the command update to apply the change sets.

这篇关于在现有数据库上使用liquibase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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