Re:How to Build a SaaS Application Block by Block
by nickmancol on Tuesday November 27, 2018 @10:46PM
(#18549150)
Maybe something like https://schinckel.net/2017/12/20/django-multitenancy-using-p...
Re:How to Build a SaaS Application Block by Block
by vonseel on Tuesday November 27, 2018 @11:10PM
(#18549233)
That was a good read, I am going to take a look at his Github now and see where he got with it. Thanks
Re:How to Build a SaaS Application Block by Block
by vonseel on Tuesday November 27, 2018 @10:50PM
(#18549164)
Ahhh nice, I will check this and the other guy's links out!
Re:How to Build a SaaS Application Block by Block
by 33degrees on Tuesday November 27, 2018 @10:49PM
(#18549162)
You can use postgres' row level security to do this: https://www.postgresql.org/docs/9.5/ddl-rowsecurity.html
Re:How to Build a SaaS Application Block by Block
by keybits on Wednesday November 28, 2018 @10:11AM
(#18552106)
Here's an up-to-date example using Rails and Postgres row level security: https://github.com/kuroda/multi_tenancy
Re:How to Build a SaaS Application Block by Block
by config_yml on Wednesday November 28, 2018 @09:20AM
(#18551594)
I've used RLS and it works great for this. Make sure you have your tenant_id on all tables, which makes it easy to partition later. I think you can even do per-tenant backups/archives like this with pgdump, by using a specific user.
Re:How to Build a SaaS Application Block by Block
by platform on Wednesday November 28, 2018 @07:40AM
(#18551006)
If you have a way of 'presetting' in advance the number of tenants.
You could use Postgres's partial indexes. (basically an index scoped per tenant).
Your 'WHERE' clauses would need to include the field indexed by those partial indexes.
https://devcenter.heroku.com/articles/postgresql-indexes#par...
I have not thought more though this, but may be combining that with the PG 11s partitioning, would get me even closer to tenant-specific archiving/backup and other admin tasks beyond query.
Re:How to Build a SaaS Application Block by Block
by abraae on Wednesday November 28, 2018 @03:31AM
(#18550057)
Oracle has Virtual Private Database
https://docs.oracle.com/cd/B28359_01/network.111/b28531/vpd....
Is there a good solution for automatically scoping a query to a tenant at the database-level (perhaps using a custom extension or PL/PgSQL to rewrite the queries), assuming the tenant_id is in the SQL request?
I guess I'm asking if it's possible to move this functionality to the database layer with something like PL/pgSQL or the Postgres rule system... both of which I know very little about.
Of course the only point in asking such a question is if there's a good reason to do it, and I can't remember why I looked into this in the first place (it's been more than a couple of years).