November 29, 2022
Handling Multiple Schemas with Liquibase
See Liquibase in Action
Accelerate database changes, reduce failures, and enforce governance across your pipelines.
![](https://cdn.prod.website-files.com/65c3a844357606c1b08a1e74/6650969d86f1aeb874ecda15_CTA%20card.webp)
Liquibase offers flexibility whether deploying changes to a single schema or multiple schemas. Depending on the database platform, there could even be a use case for deploying changes to multiple databases. An extension of this use case is that multiple schemas - or multiple databases - are shared between multiple teams, that is, multiple teams make changes to the same schemas or databases.
Whether teams are deploying to multiple dedicated schemas/databases - or multiple shared schemas/databases - it is important to pay attention to a few essential items:
- How do SQL script authors write their scripts when their scripts are deploying to multiple schemas - or databases? This typically requires prefixing all objects with the schema name - or the database name.
- Structuring your Git repository for multiple schemas - or databases - so that the Liquibase changelog file can apply the proper deployment recipe and in the correct order.
- When a single team deploys to multiple schemas - or databases - they can structure their application repository by dedicating a directory for database changes.
![](https://cdn.prod.website-files.com/65c3a844357606c1b08a1e98/65c3a844357606c1b08a234f_image001.png)
![](https://cdn.prod.website-files.com/65c3a844357606c1b08a1e98/65c3a844357606c1b08a2351_image003.png)
- When schemas – or databases – are shared across multiple teams, then it is not possible to use each team’s own application repository. This requires setting up a dedicated SQL repository for shared schemas/databases.
![](https://cdn.prod.website-files.com/65c3a844357606c1b08a1e98/65c3a844357606c1b08a2352_image005.png)
![](https://cdn.prod.website-files.com/65c3a844357606c1b08a1e98/65c3a844357606c1b08a2353_image007.png)
We have published best practices for how Liquibase can be used to handle these use cases. These also provide sample changelogs as well as a sample pipeline code, with Liquibase CLI commands, for deploying changes to multiple schemas - or databases.