CREATE TABLE "report_bookmarks" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "group_name" text NOT NULL, "unique_name" text NOT NULL, "label" text NOT NULL, "type" text NOT NULL, "applied" boolean DEFAULT false NOT NULL, "configuration" jsonb NOT NULL, "status" text DEFAULT 'draft' NOT NULL, "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "created_by" uuid NOT NULL, "updated_by" uuid NOT NULL ); --> statement-breakpoint ALTER TABLE "report_bookmarks" ADD CONSTRAINT "report_bookmarks_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "report_bookmarks" ADD CONSTRAINT "report_bookmarks_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "report_bookmarks_owner_report_type_applied_unique" ON "report_bookmarks" USING btree ("created_by","group_name","unique_name","type") WHERE "applied" = true;--> statement-breakpoint INSERT INTO "privilege_keys" ("code", "label", "sort_order") VALUES ('SALES.REPORT', 'Sales reports', 18), ('LOGISTICS.REPORT', 'Logistics reports', 19);