Re: [sqlalchemy] Postgres Row Level Security (RLS)

2021-03-04 Thread Open Ocean
that worked great. i used the rewriter with process_revision_directives to look for tenant columns in create table, add/drop column operations and add the alter table and policy commands to the version upgrade/downgrade. thanks, brian On Thursday, March 4, 2021 at 12:24:39 PM UTC-5 Mike Bayer wro

Re: [sqlalchemy] Postgres Row Level Security (RLS)

2021-03-04 Thread Mike Bayer
this is a highly postgresql-specific set of commands so using op.execute() with the ALTER commands you need seems to be the most direct and obvious way to achieve this, I'm not sure what the downside would be?if it's the redundancy, simply create a function in your applicaiton that is given

[sqlalchemy] Postgres Row Level Security (RLS)

2021-03-04 Thread Open Ocean
I'm trying to figure out how to add RLS to tables using sqlalchemy and alembic. I'm changing from schema per tenant to row per tenant in a multi-tenant db. My approach is: - use pg setting 'tenant.id' to identify the current tenant - add tenant column to tables with server_default=func.current_