CREATE TYPE "public"."project_access_token_status" AS ENUM('active', 'revoked');--> statement-breakpoint CREATE TABLE "project_access_tokens" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "project_id" uuid NOT NULL, "name" text NOT NULL, "token_prefix" text NOT NULL, "token_hash" text NOT NULL, "scopes" jsonb NOT NULL, "status" "project_access_token_status" DEFAULT 'active' NOT NULL, "last_used_at" timestamp with time zone, "revoked_at" timestamp with time zone, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "projects" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "slug" text NOT NULL, "name" text NOT NULL, "status" "project_status" DEFAULT 'active' NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "project_access_tokens" ADD CONSTRAINT "project_access_tokens_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE INDEX "project_access_tokens_project_id_idx" ON "project_access_tokens" USING btree ("project_id");--> statement-breakpoint CREATE UNIQUE INDEX "project_access_tokens_prefix_idx" ON "project_access_tokens" USING btree ("token_prefix");--> statement-breakpoint CREATE UNIQUE INDEX "project_access_tokens_hash_idx" ON "project_access_tokens" USING btree ("token_hash");--> statement-breakpoint CREATE UNIQUE INDEX "projects_slug_idx" ON "projects" USING btree ("slug");