【问题标题】:Generating liquibase xml file from current database从当前数据库生成 liquibase xml 文件
【发布时间】:2021-07-22 20:50:04
【问题描述】:

我尝试创建 MySQL 数据库中现有的 liquibase XML。我的目标是从 MySQL 数据库生成 liquibase XML 模式。

实现此解决方案的任何方式。

我已经尝试过使用 dropwizard 命令

java -jar myjar-4.1.0.jar --changeLogFile="generate.xml" --diffTypes="data" generateChangeLog

但它对我不起作用。

【问题讨论】:

  • 当您运行该命令时,实际发生了什么?你期望会发生什么? “对我不起作用”不是对问题的非常详细的描述。

标签: mysql liquibase


【解决方案1】:

试了好久终于找到了解决办法。

按照以下步骤从现有 MySQL 数据库生成迁移。 使用以下几行将初始 migrations.xml 添加到项目中。

<?xml version="1.0" encoding="UTF-8"?>
    <databaseChangeLog
            xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
             http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
    </databaseChangeLog>

运行:使用“db migrate”为 dropwizard 进行上述迁移,它将在数据库中创建 databaseChangeLog 和 databaseChangeLogLock 表。

根据要求运行以下命令。

命令语法:

liquibase --driver=com.mysql.jdbc.Driver --classpath=[path to db driver jar] --changeLogFile=[Path to above migration.xml]  --url=[Database URL] --username=[Username] --password=[Password] [command parameters]

以上常用参数可以参考linklink

注意: 命令需要 [数据库驱动 jar 的路径],如果没有,则需要 JDBC.jar 文件。

【讨论】:

    猜你喜欢
    • 2012-10-24
    • 2014-06-14
    • 1970-01-01
    • 1970-01-01
    • 2013-06-08
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多