Reputation: 23
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.
Upvotes: 2
Views: 5849
Reputation: 1631
Yes, this can be done using liquibase. If you have the setup changelog, you can do it as hinted by @htshame. Note that you will need to amend the data a bit. I also recommend to use a dedicated data-output-directory (otherwise you will get a huge XML):
liquibase.command.url
to the source server (or use the command line option)liquibase generateChangeLog --diffTypes data --data-output-directory=data --changeLogFile data.xml
will generate a data dumpliquibase.command.url
to the target serverliquibase drop-all
to (optionally clean the target DB)liquibase update --changelog-file setup.xml
will create all the tables, indices, constraints, etc.liquibase update --changelog-file data.xml
will then inject all the dataIn case you are lacking the setup.xml changelog, you can do a full dump from the existing database:
liquibase.command.url
to the source server (or use the command line option)liquibase generate-changelog --diff-types catalogs,tables,functions,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints,data,storedprocedures,triggers,sequences,databasepackage,databasepackagebody --changelog-file all.xml --data-output-directory=data
will generate a full dumpliquibase.command.url
to the target serverliquibase drop-all
to (optionally clean the target DB)liquibase update --changelog-file all.xml
will then rebuild the database on the target serverNote that in the second case, since you are using the data types of the source database, you may not have a 100% percent compliant setup. E.g. Camunda provides a setup.xml changelog and I strongly recommend to use it as it allows to integrate upcoming schema updates without difficulties.
Upvotes: 0
Reputation: 7330
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
Upvotes: 1