Liquibase-生成更改日志 [英] Liquibase - Generating Change Logs

查看:737
本文介绍了Liquibase-生成更改日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望Liquibase从此数据库测试"生成变更日志.有可能吗?

I want Liquibase, to generate a changelog, from this DB 'testing'. Is it possible?

我已经有一个现有的数据库,其中包含表和数据.

I have an existing database already, with its tables and data inside.

jdbc:mysql://localhost:3306/testing

现在,我希望Liquibase从此数据库测试"生成变更日志.有可能吗?

Now, I want Liquibase, to generate a changelog, from this DB 'testing'. Is it possible?

这是我的命令,但不起作用.

This is my command, but it doesn't work.

liquibase --driver=com.mysql.jdbc.Driver --classpath=C:\mysql-connector-java-5.1.47.jar 
--changeLogFile=C:\db.changelog.xml --url="jdbc:mysql://localhost:3306/testing"
--username=root generateChangeLog

我没有使用任何密码.

该错误与--changeLogFile = C:\ db.changelog.xml

The error is related to --changeLogFile=C:\db.changelog.xml

我认为,Liquibase将引用我的数据库测试",并在文件夹C中生成名为"db.changelog.xml"的变更日志.

I thought, Liquibase will refer to my DB 'testing', and generate changelog, with name 'db.changelog.xml' in folder C.

我错了哪一部分?我想念什么吗?

Which part I'm wrong? Do I miss something?

也许,Liquibase并非旨在从现有数据库生成变更日志?

Or maybe, Liquibase is not intended, to generate changelog, from existing DB?

或者,也许Liquibase打算仅从changelog生成数据库?反之亦然吗?

Or maybe, Liquibase is intended, to generate DB, from changelog only? And not vice versa?

推荐答案

这是可能的.由于您正在写入c:驱动器根目录中的文件,因此可能会遇到麻烦.尝试使用c:\​​ temp \ changelog.

This is possible. You might be having trouble since you are writing to a file in the root of your c: drive. Try c:\temp\changelog instead.

我的经验是liquibase可以递增工作.因此,如果您在数据库上运行该命令,它将生成一个文件,就好像必须在changelog文件中创建数据库中的所有内容一样(就像从一个完全空的数据库开始一样).

My experience is that liquibase works in increments. So if you run that command on your database, it will produce a file as if everything in the database has to be created in the changelog file (as if starting with a completely empty database).

如果您阅读了 Liquibase网站上与该命令有关的文字,则说明:

If you read the text on Liquibase's site regarding this command, it says:

开始在现有数据库上使用Liquibase时,通常有一种有用的方法,特别是对于测试而言,有一种方法来生成更改日志以创建当前数据库模式.

When starting to use Liquibase on an existing database, it is often useful, particularly for testing, to have a way to generate the change log to create the current database schema.

这意味着,如果您对自己的dev数据库执行一次该命令,对一个新数据库运行结果(比如说test),在dev数据库上再次运行它,然后对您的测试数据库运行该文件,您将得到大量错误说明功能已经存在.

This means that if you execute this command once against your dev database, run the result against a new database (let's say test), run it again on your dev database, and run that file against your test database, you will get a load of errors stating that functions already exist.

我认为这背后的想法是,您在changelog文件中创建新条目并针对所有数据库执行它们,而不是使用其他工具并使用liquibase作为增量.

I gather that the idea behind this is that you create new entries in the changelog files and executing them against ALL your databases, instead of using other tools and using liquibase for the delta.

这篇关于Liquibase-生成更改日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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