We have a multi-tenant database and this is a table in which we have implemented row-level security based on tenant_id:
tenant_id | product_id |
---|---|
0 | A |
0 | B |
1 | 1A |
1 | 1B |
2 | 2A |
2 | 2B |
Our requirement is that the products associated with tenant_id = 0 should be available to all tenants. Products associated with tenant_id != 0 should only be available to the relevant tenants.
Is there a way to implement this using security definers? Or do we need to have separate tables?