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?
Database migration is the process of migrating data from one or more source databases to one or more target databases by using a database migration service. When a migration is finished, the dataset in the source databases resides fully, though possibly restructured, in the target databases.
Yes! While Liquibase does include comparative diff capabilities, Liquibase is primarily a migration-based tool. The diff capabilities are mostly intended to assist with onboarding new projects or ensuring that your database migrations are applied correctly.
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.
Alternately, if you can stick to SQL-standard data types, they are generally fairly cross-database.
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="notes" 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"/>
The best approach is to use changelog parameters and the dbms tag.
At the top of your changeset you can include:
<property name="autoIncrement" value="true" dbms="mysql"/>
<property name="autoIncrement" value="false" dbms="oracle"/>
<property name="chartype" value="VARCHAR" dbms="mysql"/>
<property name="chartype" value="VARCHAR2" dbms="oracle"/>
Then you can have changeSets like this: Copy code
<changeSet id="1" author="a">
<createTable name="x">
<column name="id" datatype="int" autoincrement="${autoIncrement}"/>
<column name="name" datatype="${chartype}(255)" />
....
</changeSet>
<changeSet id="2" author="a" dbms="oracle">
<createSequence name="seq_x"/>
</changeSet>
EDIT source: http://forum.liquibase.org/topic/auto-increment-vs-sequences-using-liquibase-with-oracle-and-mysql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With