Peggy
Peggy

Reputation: 395

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?

Upvotes: 0

Views: 215

Answers (1)

Mike Olivas
Mike Olivas

Reputation: 313

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

Upvotes: 1

Related Questions