Working on multi-tenant database

Greetings, I am working on oracle multi-tenant database (one database having multiple schemas). Let’s say I have 3 schemas A, B and C. currently I am creating 3 different changelogs for each of the schema (A.xml, B.xml, and C.xml) and also different properties files (A.prop, B.prop, and C.prop) In this way I am able to execute changelogs on the schemas. this approach however creates databasechangelog table on each of the schema. I was wondering if I could create one master schema M(having granted access to all A, B & C) having single master.xml and properties files ?? Really appreciate your answer, Thanks

I read on the documentation that liquibase has schemaName attribute, but it is the attribute for createTable tag. Is there an attribute for a changeset where we can specify the schema name ?

Hi @Akshayware,
i suggest you to use 3 different liquibase properties file and point to the same changelog master.xml file if you want to apply the same update to all databases.

KR,
Costin

1 Like

@Akshayware ,

@costinmoraru has a good suggestion for using the same changelog with multiple environments. I would also suggest if you want to set schema name dynamically (as in it may be different in different enviropnment) then you can use property substitution for the schema name.

For example you can say:
${schema.name}.tableName

Thanks for your reply @ronak @costinmoraru. Really appreciate it. In my case, all the schemas have different changes in them so I use different master.xml for each of the schemas. Instead of spamming all the schemas with databaseChangelog table, I was wondering if I can use a single databaseChangelog table for all the schemas. I know that mentioning liquibaseSchema= we can mention the schema in which databaseChangelog table would be created. but will that work for multiple schemas (pointing to the same databasechangelog ) having different changes in each of the schema ? Thank You !

Hi @Akshayware,
A little confused on your question. the databasechangelog can track changes from diff changelog files (the rows contain a column for which changelog file it came from, so it won’t get confused between 2 changelog files).
And of course, you are welcome, we want to help.

Yes, this solves my question @costinmoraru. This will help me use liquibase for multiple schemas and having a single tracking table. Thank you.