douglasjarquin
01/28/2022, 2:26 PMdouglasjarquin
01/28/2022, 2:28 PMktosiek
01/28/2022, 3:15 PMsilentworks
01/28/2022, 4:46 PMdouglasjarquin
01/28/2022, 5:39 PMsql
CREATE TABLE "public"."projects" (
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"title" text,
"track_count" int2 DEFAULT '0'::smallint,
"is_active" bool DEFAULT true,
"is_deleted" bool DEFAULT false,
"updated_at" timestamptz DEFAULT (now() AT TIME ZONE 'utc'::text),
"created_at" timestamptz DEFAULT (now() AT TIME ZONE 'utc'::text),
"created_by" uuid,
CONSTRAINT "projects_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "auth"."users"("id"),
PRIMARY KEY ("id")
);
Here's my test query:
sql
select * from projects
where is_active = true
AND id IN (
select project_id
from collaborators
where user_id = '3932c061-b49a-42f8-9d6a-435c0383d00e'
)
douglasjarquin
01/28/2022, 5:41 PMcollaborators
is a basic many-to-many, and I replace the user_id string with auth.uid()
in my policy.douglasjarquin
01/28/2022, 5:48 PMdouglasjarquin
01/28/2022, 6:06 PMprojects
table policy being the problem that I didn't look at my collaborators
table policies. Only had an INSERT policy there, so added a SELECT policy and voila.silentworks
01/28/2022, 6:52 PM