数据库迁移与Liquibase使用不同的DBMS [英] Database Migration with Liquibase using different DBMS

查看:1201
本文介绍了数据库迁移与Liquibase使用不同的DBMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的客户使用Oracle,我们想使用MySQL进行开发。因此,我们的MySQL方案必须与Oracle同步。我试图使用Liquibase,但是在应用一个更改集时,由于数据库特定的sql和不同的列类型,如NUMBER< - > - > BIGINT或VARCHAR< - > - VARCHAR2

Our customer is using Oracle and we want to use MySQL for development. Therefore our MySQL Scheme has to be in sync with Oracle. I tried to use Liquibase, but I get problems at the time of applying a changeset because of the db specific sql and different column types like NUMBER <-> BIGINT or VARCHAR <-> VARCHAR2

我使用这些工具错了吗?如何解决这类问题?

Am I using these tools wrong? How to solve this type of problem?

推荐答案

Liquibase将尝试转换标准类型,如varchar,int boolean,datetime更改为数据库的正确数据类型。如果将列定义为type =VARCHAR(100),则当针对oracle运行时,它将使用VARCHAR2(100)生成SQL。

Liquibase will attempt to convert standard types like "varchar", "int", "boolean", "datetime" to the correct datatype for the database. If you define a column as type="VARCHAR(100)", when you run against oracle it will generate SQL with VARCHAR2(100).

不幸的是,标准类型与数据库特定类型的映射没有记录在案。

The mapping of standard types to database-specific types is not as well documented as it should be, unfortunately.

另外,如果你可以坚持使用SQL标准的数据类型,它们通常是相当跨数据库。

Alternately, if you can stick to SQL-standard data types, they are generally fairly cross-database.

当你需要强制一个特定的类型,你可以使用一个changelog参数,如 http://www.liquibase.org/documentation/changelog_parameters.html

When you need to force a particular type, you can use a changelog parameter like the example in http://www.liquibase.org/documentation/changelog_parameters.html

< column name =notestype =$ {clob.type}/>

并为每个数据库定义clob.type:

and define clob.type per database:

<property name="clob.type" value="clob" dbms="oracle"/>
<property name="clob.type" value="longtext" dbms="mysql"/>

这篇关于数据库迁移与Liquibase使用不同的DBMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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