snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
8
examples/rls/migrations/20240714101101.sql
Normal file
8
examples/rls/migrations/20240714101101.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
-- Create "users" table
|
||||
CREATE TABLE "users" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, "tenant_id" bigint NOT NULL, PRIMARY KEY ("id"));
|
||||
-- Enable row-level security for "users" table
|
||||
ALTER TABLE "users" ENABLE ROW LEVEL SECURITY;
|
||||
-- Create policy "tenant_isolation"
|
||||
CREATE POLICY "tenant_isolation" ON "users" AS PERMISSIVE FOR ALL TO PUBLIC USING (tenant_id = (current_setting('app.current_tenant'::text))::integer);
|
||||
-- Create "tenants" table
|
||||
CREATE TABLE "tenants" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, PRIMARY KEY ("id"));
|
||||
Reference in New Issue
Block a user