Files
image-platform/packages/database/drizzle/0004_complex_yellowjacket.sql
S.Gromov 98295d0569 feat: добавить новый backend и cabinet
- добавлен новый Nest backend для auth, projects и project access tokens
- добавлена control-plane схема БД и миграция Drizzle
- перенесён старый backend в old-backend
- добавлен React/Vite cabinet с auth-only входом и Mantine layout
- обновлены workspace scripts и lockfile
2026-05-12 09:22:04 +03:00

29 lines
1.6 KiB
SQL

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");