0034_briven_auth_sdk_keys.sql27 lines · main
1-- 0034_briven_auth_sdk_keys — create the missing Auth → API Keys table.
2--
3-- `briven_auth_sdk_keys` exists in the Drizzle schema (db/schema.ts) but no
4-- migration ever created it (the schema-diff needs a TTY — road-to-ga §2.9 —
5-- so it was never generated). Result: the auth → api-keys panel 500'd with a
6-- "relation does not exist" against this table. This lands it on the control
7-- DB (real Postgres). IF NOT EXISTS guards keep it safe if a partial create
8-- ever ran.
9CREATE TABLE IF NOT EXISTS "briven_auth_sdk_keys" (
10 "id" text PRIMARY KEY NOT NULL,
11 "project_id" text NOT NULL,
12 "created_by" text NOT NULL,
13 "name" text NOT NULL,
14 "hash" text NOT NULL,
15 "prefix" text NOT NULL,
16 "suffix" varchar(4) NOT NULL,
17 "scope" text DEFAULT 'read' NOT NULL,
18 "last_used_at" timestamp with time zone,
19 "expires_at" timestamp with time zone,
20 "created_at" timestamp with time zone DEFAULT now() NOT NULL,
21 "revoked_at" timestamp with time zone,
22 CONSTRAINT "briven_auth_sdk_keys_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action,
23 CONSTRAINT "briven_auth_sdk_keys_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action
24);
25--> statement-breakpoint
26CREATE UNIQUE INDEX IF NOT EXISTS "briven_auth_sdk_keys_hash_idx" ON "briven_auth_sdk_keys" USING btree ("hash");--> statement-breakpoint
27CREATE INDEX IF NOT EXISTS "briven_auth_sdk_keys_project_idx" ON "briven_auth_sdk_keys" USING btree ("project_id");