Skip to content

Multi Tenant Database Migration with Liquibase #35378

Closed Answered by lusabo
lusabo asked this question in Q&A
Discussion options

You must be logged in to vote

I improved the code above:

public void runLiquibase(String schema) {
        LOG.info(String.format("Running Liquibase for the new schema: %s", schema));
        try (Connection connection = dataSource.getConnection()) {
            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
            database.setDefaultSchemaName(schema);
            Liquibase liquibase = new Liquibase("db/db.changelog-tenant.yaml", new ClassLoaderResourceAccessor(), database);
            liquibase.update(new Contexts(), new LabelExpression());
            LOG.info(String.format("Liquibase update complete for schema: %s", schema));
        } catch

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lusabo
Comment options

Answer selected by lusabo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
1 participant