We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
This post describes my efforts and approach to multi tenancy for a couple of Elixir/Phoenix/Ecto B2B applications Iโm working on. Hopefully, it will provide a fairly complete example for those looking to implement something similar, and help avoid a bunch of digging that I found myself doing.
Since there are many different styles/implementations of multi tenancy, here is what I was trying to accomplish:
- I should be able to centrally define a list of tenants and store some additional per-tenant meta-data.
- For each tenant, I can configure one or more domains associated with that tenant.
- When the site is accessed, the domain is looked up to determine which, if any, tenant is associated with that domain.
- If a domain isnโt owned by any tenant, raise an error.
- Most (but not all) objects in the database are owned by a tenant. Put differently, I need the ability to have some data which is common among tenants.
- I, obviously, want to make it difficult (impossible, ideally) for data to accidentally bleed across tenants.
Additionally,
- I would like to be able to run reports / administrative actions which run across all tenants.
- I would like easy automated deployment to all tenants. (i.e. I donโt want to be fighting against all of Ectoโs great functionality)
For this post, and these projects, Iโve settled on foreign-key style multi tenancy, but here are the options I considered.
continue reading on www.erraticbits.ca
โ ๏ธ This post links to an external website. โ ๏ธ
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.