CREATE TABLE "fhir_api_keys" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "organization_id" text NOT NULL, "name" text NOT NULL, "key_hash" text NOT NULL, "created_by" text, "created_at" timestamp DEFAULT now() NOT NULL, "last_used_at" timestamp, "revoked_at" timestamp, CONSTRAINT "fhir_api_keys_key_hash_unique" UNIQUE("key_hash") ); --> statement-breakpoint ALTER TABLE "fhir_api_keys" ADD CONSTRAINT "fhir_api_keys_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "fhir_api_keys" ADD CONSTRAINT "fhir_api_keys_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint CREATE INDEX "fhir_api_keys_org_idx" ON "fhir_api_keys" USING btree ("organization_id");