Multi-tenancywith PostgreSQL
Three waysbit.ly/msn-multitenant-arch
Shared Database, Shared Namespace
Shared Database,Separate Namespace
Guy Naor on Multi-tenancyhttp://bit.ly/guy-naor-multitenant-2009
carding.app.com/products/1-grapes
SET SEARCH_PATH = 'carding'
'carding'
SELECT * FROM products where id = 1;
'carding'
SELECT * FROM public.invoices where tenant_id = 1;
Apartmentgithub.com/bradrobertson/apartment
Storeygithub.com/ramontayag/storey
Problem: Testing
● transactions do not play well with schemas
Answer: Testing
● in tests, treat the public schema as a tenant
Answer: Apartment/Storey
● loops through the namespaces and migrates each one
Problem: Background Jobs
● how do the workers know which schema contains the data?
Answer: Pass schema name
● Pass the schema name along with the rest of the job arguments