Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/dbagent/migrations/0008_public-chats.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TYPE "public"."visibility" AS ENUM('public', 'private');

--> statement-breakpoint
CREATE ROLE "anonymous_user";

--> statement-breakpoint
ALTER TABLE
"chats"
ADD
COLUMN "visibility" "visibility" DEFAULT 'private' NOT NULL;

--> statement-breakpoint
CREATE POLICY "chats_anonymous_policy" ON "chats" AS PERMISSIVE FOR
SELECT
TO "anonymous_user" USING (visibility = 'public');

--> statement-breakpoint
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "anonymous_user";

--> statement-breakpoint
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO "anonymous_user";
Loading
Loading