Just getting started with Metabase. We have a database where each tenant in our service is in a separate named schema, to keep client data segregated. Each tenant’s schema table structure is exactly the same. It is a single database connection.
How can we set up models/metrics/questions to be reused across the schemas?
What database are you using?
Your problem is usually solved with either impersonation or database routing. Both of these are in the paid version of Metabase. Metabase sales might be able to guide you on this.
I think the usual expectation in Metabase for multi-tenant is customer-per-database rather than customer-per-schema. Metabase is schema aware, so it’s not as easy to reuse questions with different schemas, but I haven’t tried doing that sort of thing so I may be missing something that helps enable it.
Thanks, we’re using Postgres.
I could make database routing work internally but we want to use embedding, and routing is only available in interactive embedding. It’s not viable for us to use interactive embedding given the current pricing model (every user in our tool would need to be a paid Metabase user).
I have reached out to Metabase directly as well, hopefully there is a solution here.
I can think of some pretty heinous hackarounds for tenant-per-schema schemes (involving table-returning functions that take a schema as an argument, or a mega-view that glues the same table from each schema together with the schema name as a column) but I don’t see performance being great or the whole scheme being scalable without automation.
If you didn’t need to reuse questions (i.e., for purely self-service analytics), you could have separate database connections per user and use permissions to enforce the access. This scheme is described here. You end up with one database connection per Metabase user (or group), which doesn’t scale great, but at least you don’t have to reinvent your schemas for Metabase.