Many users have heard of Liquibase, an open source library (Apache 2.0 License) that allows you to store, track, and apply database changes. And someone, for sure, used it for the database refactoring. Today we will talk about the unusual usage of such utility - the conversion of the database scheme.
During the process of developing any software (especially if it was originally developed to meet the requirements of a particular customer),
sooner or later the question of moving the functionality to another platform may arise.
Can your application store data in MS SQL Server? We do not have the opportunity to hire a separate DBA to maintain PostgreSQL!
Let's convert the data model in Oracle Data Modeler format!
Its good if the solution was initially designed to use may different RDBMS. Or the DBMS has the ability to store data in an external database (such as OpenEdge Data Server for Oracle). But what about the others? Looking for a solution on the Internet? Is it possible to write a converter by itself, by mapping tables and fields, by matching data types?
The Liquibase library, designed for managing the version of the database, can help the developer.
With Liquibase, it is enough to create an initial snapshot of the database schema in XML format, which can then be uploaded as an SQL dump.
The following is an example for the PostgreSQL database that migrates to Oracle.
./liquibase --url=jdbc:postgresql://127.0.0.1:5432/demo \ --driver=org.postgresql.Driver --username="user" \ --password="password" \ --changeLogFile=demo.changelog.xml generateChangeLog
./liquibase --url=offline:oracle --changeLogFile=demo.changelog.xml updateSQL > changelog.sql