Hello HN, I'm building a SaaS product. Each tenant can have their own database structure/fields while many tables are common between the tenants.
For example table A is common for all of them while table B might have different fields upon organization/tenant's need, in other words we have table B for all orgs with different fields.<p>I'm thinking of shared-codebase and shared-database paradigm for it's simplicity(no synchronization needed). Have you encountered this situation? Is it possible/and how to handle this objective with single database for all tenants? Further, I'm using PostgreSQL database.<p>Thanks in advance.
You're heading the right way. A correct design is not simple, but it can be done. You might be able to buy a boilerplate that'll work as a starting point.<p>Separate database will only work if you'll have a handful of customers, and even then a pain.
Possible to do with one database, yes - Add JSON columns to your tables to hold tenant-specific metadata. Deal with it in your app layer.<p>But I'd re-think whether a single database is truly the right answer. What is driving you to that solution?