'Liquibase insert from old database into new schema
I have a database user with access to 2 schemas, oldDb and newDb and I want to select everything from oldDb.users
table and insert them into newDb.users
using Liquibase.
I want to be able to not to hard code the schema names because I want to test the code locally and in different test environments before running it on real data, and in test environments the names of the schemas are different. Is there a way to do this?
Solution 1:[1]
One high level way might be to run
liquibase generateChangeLog
against oldDB to pull out the table. Then do a global replace of the oldDB. schema name with the new schema name newDB. A second option would be to do the global replace of oldDB. with a ${replaceSchema} and then add a property to your changelog called replaceSchema or at runtime provide the parameter.
More details here https://docs.liquibase.com/concepts/changelogs/property-substitution.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mike Olivas |