从头开始构建liquibase数据库

Pau*_*ley 5 mysql liquibase

当我从头开始运行 liquibase update 时,该过程会一一触发每个变更日志,这需要一段时间。有时,我自己的数据库更改差异很大,例如,如果我想重新开始,则最容易重建数据库。

如果我在变更日志中的某个点从 liquibase 结果的 mysql 转储中进行重建,那么重建将是最快的,并且我之前忽略了那里的变更日志。因此,我会删除主变更日志中的所有内容,除了主构建转储变更日志(这将是整个数据库),并且出于版本控制原因,我保留实际的变更日志。

是否有适当/指定/安全的方法从 liquibase 执行此操作?

Nat*_*and 2

不幸的是,没有“重新启动”变更日志文件的标准方法,因为您的环境和设置会极大地影响最适合您的方法。

Often times the easiest approach is to not completely restart your changelog file but instead make modifications to it. Databases are generally fast at DDL, especially on an empty database and so often times what makes a clean database rebuild is a small portion of the changeSets. Re-defining indexes are often a big part of the problem, but other things can be as well. Watch what changeSets take a log time and perhaps you can find some that cancel each other out or are now unneeded but still take up a bulk of the time.

If it will work best for you to start from scratch, the process is basically the same as starting to use Liquibase on an existing project. See the documentation at http://www.liquibase.org/documentation/existing_project.html for ideas on options with this.

With mysql one option may be to use mysqldump and then have a single changeSet using <execute> to call the mysql restore shell command.

对于现有的数据库变更日志行,Liquibase 使用该路径作为变更集标识符的一部分,因此如果您的新变更日志文件具有不同的名称或路径,Liquibase 已经将变更集视为新的。<changeSet>或者,您可以使用执行以下操作的文件来启动新的变更日志文件:delete from databasechangelog