Does this have easy support for some kind of sub-tenant setup?
Following your example, let's say that most customers have multiple departments and that most tables have both a customer_id and a department_id.
Oh, and this looks solid. Nice work :)
Following your example, let's say that most customers have multiple departments and that most tables have both a customer_id and a department_id.
Oh, and this looks solid. Nice work :)
You could probably do it nonetheless with Rails' own has_many/belongs_to relationships for that sub-tenant, but the automatic adding of department_id into queries wouldn't happen.
Depending on what storage you end up using, that might matter or not. For example with Citus, you'd typically take the top-level tenant (customer_id) as a shard key, and just have all the departments of that tenant on the same node - so it would work fine.