首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Liquibase命令行在sql中创建比较更改日志

Liquibase命令行在sql中创建比较更改日志
EN

Stack Overflow用户
提问于 2013-06-05 23:02:31
回答 2查看 17.7K关注 0票数 8

我实际上在命令行中使用windows上的Liquibase,并尝试创建一个sql脚本来表示两个数据库之间的差异。不幸的是,我只能得到xml文件作为回报。你能帮我吗?

我的命令行:

代码语言:javascript
运行
复制
liquidbase.bat 
   --driver=com.mysql.jdbc.Driver 
   --url=jdbc:mysql://localhost:3306/base1 
   --username=root 
   diffChangeLog 
   --referenceUrl=jdbc:mysql://localhost:3306/base2 
   --referenceUsername=root 
> test.sql

我在其他论坛上看到过类似的问题,但他没有得到一个好的答案(http://forum.liquibase.org/topic/convert-changelog-xml-file-into-sql-file)。我还看到了一些用于从sql获取updateSQL文件的参数,但从未用于diffChangeLog。

xml反馈示例:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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-2.0.xsd">
    <changeSet author="user (generated)" id="1370443156612-1">
        <createTable tableName="test">
            <column name="a" type="INT"/>
        </createTable>
    </changeSet>
    <changeSet author="user (generated)" id="1370443156612-2">
        <addColumn tableName="articles">
            <column name="date_debut" type="TEXT">
                <constraints nullable="false"/>
            </column>
        </addColumn>
    </changeSet>

谢谢您的提前付款。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-09 00:51:53

您正在运行diffChangeLog命令,我想您需要diff命令?请参见manual中的输出模式。

代码语言:javascript
运行
复制
liquibase.bat 
  --driver=com.mysql.jdbc.Driver 
  --url=jdbc:mysql://localhost:3306/base1 
  --username=root 
  --referenceUrl=jdbc:mysql://localhost:3306/base2 
  --referenceUsername=root 
  diff
    > test.sql
票数 0
EN

Stack Overflow用户

发布于 2014-06-03 19:51:03

diff命令仅提供差异的文本概述。

为了获得新(dev)和旧数据库的差异的SQL:

  1. 使用diffChangeLog通过比较两个数据库来(可能是暂时的)更新您的changelog
  2. 使用updateSQL对过时的数据库进行更新,以显示为使其最新而运行的sql命令。注意,打印的SQL还将包含用于administration.

的liquibase所需的命令。

如果新的/dev数据库是您所期望的,那么可以将新的changelog与您的代码一起提交。使用changelogSync让新的/dev数据库认为它已经被liquibase更新了。

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16943302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档