callistaenterprise / blog-multitenancy

Sample application demonstrating dynamic Multi-tenancy with Spring Boot, Hibernate and Liquibase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can you create a separate db + multi schema variation?

tosehee opened this issue · comments

Can you create a separate db + multi schema variation?

For example, one tenant might use the db by itself, but smaller tenants may reside in the same db, but in its own schema.

I'd assume this is very similar to the database branch. But must create the map of Tenant ID to DataSource, and call the "setCatalog" on the Connection before it's returned.

Other than, do you see any other things that need to be incorporated?

ping

You're right, the two patterns can be combined just like you describe. In https://callistaenterprise.se/blogg/teknik/2022/03/26/multi-tenancy-with-spring-boot-part7/ I describe a similar, hybrid pattern (combining the database-per-tenant with shared-database to achieve sharding.