databasemigrationliquibasedata-migrationliquibase-hibernate

Does liquibase support data migration from one database to another


I have a scenario where we are migrating from Oracle DB to Postgres Sql, I know I can generate a change-log from Oracle schema using liquibase maven plugin and can use the same to create my schema in Postgres. What i want to know is if its possible to copy the data from oracle to postgresql too using liquibase. If so, how to do it.

Any help is much appreciated.


Solution

  • I'm not sure you can copy the data from one database to another using Liquibase changeSet directly.

    But you can use generateChangeLog with --diffTypes=data attribute. It'll include data in the generated changeSets.

    Check out the generateChangeLog docs

    –diffTypes - List of diff types to include in changelog expressed as a comma separated list from: tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data.

    And also check out this example

    liquibase   
            --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver  
            --classpath="C:\\Program Files\\Microsoft JDBC Driver 6.0 for SQL Server\\sqljdbc_6.0\\enu\\jre8"  
            --url="jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks2017;integratedSecurity=false;"
            --changeLogFile="D:\Source\generateChangeLog--PersonSchema.xml"
            --username=liquibase
            --password=liquibase@123
            --logLevel=info
            --defaultSchemaName=dbo
            --diffTypes=data
            generateChangeLog