Release v1.0.0
This commit is contained in:
356
server/drizzle/0000_last_spectrum.sql
Normal file
356
server/drizzle/0000_last_spectrum.sql
Normal file
@@ -0,0 +1,356 @@
|
||||
CREATE TYPE "public"."asset_status" AS ENUM('DRAFT', 'GENERATING', 'REVIEW', 'APPROVED', 'ARCHIVED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."asset_type" AS ENUM('CHARACTER', 'SCENE', 'PROP', 'VOICE', 'MUSIC');--> statement-breakpoint
|
||||
CREATE TYPE "public"."delivery_status" AS ENUM('DRAFT', 'QUEUED', 'PUBLISHING', 'PUBLISHED', 'FAILED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."episode_status" AS ENUM('OUTLINE', 'SCRIPTING', 'STORYBOARDING', 'PRODUCTION', 'REVIEW', 'PUBLISHED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."job_status" AS ENUM('QUEUED', 'RUNNING', 'SUCCEEDED', 'FAILED', 'CANCELLED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."job_type" AS ENUM('SCRIPT_GENERATE', 'ASSET_GENERATE', 'TTS_GENERATE', 'VIDEO_GENERATE', 'LIPSYNC_GENERATE', 'EPISODE_RENDER', 'DELIVERY_PUBLISH');--> statement-breakpoint
|
||||
CREATE TYPE "public"."membership_role" AS ENUM('OWNER', 'ADMIN', 'EDITOR', 'REVIEWER', 'VIEWER');--> statement-breakpoint
|
||||
CREATE TYPE "public"."project_status" AS ENUM('DRAFT', 'ACTIVE', 'ARCHIVED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."render_status" AS ENUM('QUEUED', 'RENDERING', 'REVIEW', 'APPROVED', 'FAILED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."review_status" AS ENUM('OPEN', 'APPROVED', 'CHANGES_REQUESTED', 'CANCELLED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."review_target_type" AS ENUM('SCRIPT_VERSION', 'ASSET_VERSION', 'SHOT_VERSION', 'RENDER');--> statement-breakpoint
|
||||
CREATE TYPE "public"."shot_status" AS ENUM('DRAFT', 'GENERATING', 'REVIEW', 'APPROVED', 'RENDERED');--> statement-breakpoint
|
||||
CREATE TYPE "public"."usage_kind" AS ENUM('TEXT_INPUT_TOKEN', 'TEXT_OUTPUT_TOKEN', 'IMAGE', 'AUDIO_SECOND', 'VIDEO_SECOND', 'RENDER_SECOND', 'STORAGE_BYTE_MONTH');--> statement-breakpoint
|
||||
CREATE TABLE "asset_versions" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"asset_id" uuid NOT NULL,
|
||||
"version" integer NOT NULL,
|
||||
"storage_key" text,
|
||||
"thumbnail_key" text,
|
||||
"mime_type" varchar(120),
|
||||
"byte_size" integer,
|
||||
"width" integer,
|
||||
"height" integer,
|
||||
"duration_ms" integer,
|
||||
"prompt" text DEFAULT '' NOT NULL,
|
||||
"negative_prompt" text DEFAULT '' NOT NULL,
|
||||
"provider" varchar(80),
|
||||
"provider_model" varchar(160),
|
||||
"seed" varchar(80),
|
||||
"generation_params" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"is_current" boolean DEFAULT false NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "assets" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"project_id" uuid NOT NULL,
|
||||
"type" "asset_type" NOT NULL,
|
||||
"name" varchar(180) NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"status" "asset_status" DEFAULT 'DRAFT' NOT NULL,
|
||||
"tags" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "audit_logs" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid,
|
||||
"actor_id" uuid,
|
||||
"action" varchar(120) NOT NULL,
|
||||
"resource_type" varchar(80) NOT NULL,
|
||||
"resource_id" uuid,
|
||||
"ip_address" varchar(64),
|
||||
"user_agent" text,
|
||||
"before" jsonb,
|
||||
"after" jsonb,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "deliveries" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"render_id" uuid NOT NULL,
|
||||
"platform" varchar(80) NOT NULL,
|
||||
"status" "delivery_status" DEFAULT 'DRAFT' NOT NULL,
|
||||
"destination" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"external_id" varchar(255),
|
||||
"published_url" text,
|
||||
"scheduled_at" timestamp with time zone,
|
||||
"published_at" timestamp with time zone,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"error_message" text,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "episodes" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"project_id" uuid NOT NULL,
|
||||
"episode_number" integer NOT NULL,
|
||||
"title" varchar(200) NOT NULL,
|
||||
"synopsis" text DEFAULT '' NOT NULL,
|
||||
"target_duration_seconds" integer DEFAULT 180 NOT NULL,
|
||||
"status" "episode_status" DEFAULT 'OUTLINE' NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "generation_jobs" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"project_id" uuid,
|
||||
"episode_id" uuid,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"type" "job_type" NOT NULL,
|
||||
"status" "job_status" DEFAULT 'QUEUED' NOT NULL,
|
||||
"progress" integer DEFAULT 0 NOT NULL,
|
||||
"provider" varchar(80),
|
||||
"provider_model" varchar(160),
|
||||
"external_id" varchar(255),
|
||||
"idempotency_key" varchar(180) NOT NULL,
|
||||
"input" jsonb NOT NULL,
|
||||
"output" jsonb,
|
||||
"error_code" varchar(100),
|
||||
"error_message" text,
|
||||
"attempts" integer DEFAULT 0 NOT NULL,
|
||||
"max_attempts" integer DEFAULT 3 NOT NULL,
|
||||
"started_at" timestamp with time zone,
|
||||
"completed_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 "memberships" (
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"role" "membership_role" DEFAULT 'VIEWER' NOT NULL,
|
||||
"invited_by_id" uuid,
|
||||
"joined_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "memberships_workspace_id_user_id_pk" PRIMARY KEY("workspace_id","user_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "projects" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"name" varchar(180) NOT NULL,
|
||||
"slug" varchar(100) NOT NULL,
|
||||
"logline" text DEFAULT '' NOT NULL,
|
||||
"genre" varchar(80) DEFAULT '都市悬疑' NOT NULL,
|
||||
"visual_bible" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"status" "project_status" DEFAULT 'DRAFT' NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "refresh_tokens" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"token_hash" text NOT NULL,
|
||||
"expires_at" timestamp with time zone NOT NULL,
|
||||
"revoked_at" timestamp with time zone,
|
||||
"replaced_by_id" uuid,
|
||||
"user_agent" text,
|
||||
"ip_address" varchar(64),
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "renders" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"episode_id" uuid NOT NULL,
|
||||
"version" integer NOT NULL,
|
||||
"status" "render_status" DEFAULT 'QUEUED' NOT NULL,
|
||||
"storage_key" text,
|
||||
"thumbnail_key" text,
|
||||
"mime_type" varchar(120) DEFAULT 'video/mp4' NOT NULL,
|
||||
"byte_size" integer,
|
||||
"duration_ms" integer,
|
||||
"width" integer NOT NULL,
|
||||
"height" integer NOT NULL,
|
||||
"fps" integer DEFAULT 24 NOT NULL,
|
||||
"settings" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"quality_report" jsonb,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "review_comments" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"review_request_id" uuid NOT NULL,
|
||||
"author_id" uuid NOT NULL,
|
||||
"body" text NOT NULL,
|
||||
"timecode_ms" integer,
|
||||
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "review_requests" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"target_type" "review_target_type" NOT NULL,
|
||||
"target_id" uuid NOT NULL,
|
||||
"status" "review_status" DEFAULT 'OPEN' NOT NULL,
|
||||
"requested_by_id" uuid NOT NULL,
|
||||
"assigned_to_id" uuid,
|
||||
"resolved_by_id" uuid,
|
||||
"summary" text DEFAULT '' NOT NULL,
|
||||
"resolved_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 "script_versions" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"episode_id" uuid NOT NULL,
|
||||
"version" integer NOT NULL,
|
||||
"title" varchar(200) NOT NULL,
|
||||
"content" jsonb NOT NULL,
|
||||
"plain_text" text DEFAULT '' NOT NULL,
|
||||
"change_summary" text DEFAULT '' NOT NULL,
|
||||
"is_current" boolean DEFAULT false NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "shot_versions" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"shot_id" uuid NOT NULL,
|
||||
"version" integer NOT NULL,
|
||||
"image_asset_version_id" uuid,
|
||||
"video_storage_key" text,
|
||||
"audio_storage_key" text,
|
||||
"subtitle_text" text DEFAULT '' NOT NULL,
|
||||
"generation_params" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"is_current" boolean DEFAULT false NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "shots" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"episode_id" uuid NOT NULL,
|
||||
"shot_number" integer NOT NULL,
|
||||
"scene_number" integer NOT NULL,
|
||||
"title" varchar(180) NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"shot_type" varchar(50) DEFAULT '中景' NOT NULL,
|
||||
"camera_motion" varchar(50) DEFAULT '静止' NOT NULL,
|
||||
"duration_ms" integer DEFAULT 3000 NOT NULL,
|
||||
"status" "shot_status" DEFAULT 'DRAFT' NOT NULL,
|
||||
"character_asset_ids" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||
"scene_asset_id" uuid,
|
||||
"sort_order" integer NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "usage_ledger" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"user_id" uuid,
|
||||
"job_id" uuid,
|
||||
"kind" "usage_kind" NOT NULL,
|
||||
"quantity" numeric(20, 4) NOT NULL,
|
||||
"credits" numeric(20, 4) NOT NULL,
|
||||
"provider_cost_usd" numeric(20, 6),
|
||||
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"occurred_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "users" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"email" varchar(320) NOT NULL,
|
||||
"display_name" varchar(120) NOT NULL,
|
||||
"password_hash" text NOT NULL,
|
||||
"avatar_key" text,
|
||||
"email_verified_at" timestamp with time zone,
|
||||
"disabled_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 "workspaces" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"name" varchar(160) NOT NULL,
|
||||
"slug" varchar(80) NOT NULL,
|
||||
"owner_id" uuid NOT NULL,
|
||||
"plan" varchar(32) DEFAULT 'PRO' NOT NULL,
|
||||
"monthly_credit_limit" integer DEFAULT 10000 NOT NULL,
|
||||
"settings" jsonb DEFAULT '{}'::jsonb 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 "asset_versions" ADD CONSTRAINT "asset_versions_asset_id_assets_id_fk" FOREIGN KEY ("asset_id") REFERENCES "public"."assets"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "asset_versions" ADD CONSTRAINT "asset_versions_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "assets" ADD CONSTRAINT "assets_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "assets" ADD CONSTRAINT "assets_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_actor_id_users_id_fk" FOREIGN KEY ("actor_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD CONSTRAINT "deliveries_render_id_renders_id_fk" FOREIGN KEY ("render_id") REFERENCES "public"."renders"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD CONSTRAINT "deliveries_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "episodes" ADD CONSTRAINT "episodes_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "episodes" ADD CONSTRAINT "episodes_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "generation_jobs" ADD CONSTRAINT "generation_jobs_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "generation_jobs" ADD CONSTRAINT "generation_jobs_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "generation_jobs" ADD CONSTRAINT "generation_jobs_episode_id_episodes_id_fk" FOREIGN KEY ("episode_id") REFERENCES "public"."episodes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "generation_jobs" ADD CONSTRAINT "generation_jobs_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "memberships" ADD CONSTRAINT "memberships_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "memberships" ADD CONSTRAINT "memberships_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "memberships" ADD CONSTRAINT "memberships_invited_by_id_users_id_fk" FOREIGN KEY ("invited_by_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "projects" ADD CONSTRAINT "projects_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "projects" ADD CONSTRAINT "projects_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "refresh_tokens" ADD CONSTRAINT "refresh_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "renders" ADD CONSTRAINT "renders_episode_id_episodes_id_fk" FOREIGN KEY ("episode_id") REFERENCES "public"."episodes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "renders" ADD CONSTRAINT "renders_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "review_comments" ADD CONSTRAINT "review_comments_review_request_id_review_requests_id_fk" FOREIGN KEY ("review_request_id") REFERENCES "public"."review_requests"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "review_comments" ADD CONSTRAINT "review_comments_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "review_requests" ADD CONSTRAINT "review_requests_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "review_requests" ADD CONSTRAINT "review_requests_requested_by_id_users_id_fk" FOREIGN KEY ("requested_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "review_requests" ADD CONSTRAINT "review_requests_assigned_to_id_users_id_fk" FOREIGN KEY ("assigned_to_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "review_requests" ADD CONSTRAINT "review_requests_resolved_by_id_users_id_fk" FOREIGN KEY ("resolved_by_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "script_versions" ADD CONSTRAINT "script_versions_episode_id_episodes_id_fk" FOREIGN KEY ("episode_id") REFERENCES "public"."episodes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "script_versions" ADD CONSTRAINT "script_versions_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "shot_versions" ADD CONSTRAINT "shot_versions_shot_id_shots_id_fk" FOREIGN KEY ("shot_id") REFERENCES "public"."shots"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "shot_versions" ADD CONSTRAINT "shot_versions_image_asset_version_id_asset_versions_id_fk" FOREIGN KEY ("image_asset_version_id") REFERENCES "public"."asset_versions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "shot_versions" ADD CONSTRAINT "shot_versions_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "shots" ADD CONSTRAINT "shots_episode_id_episodes_id_fk" FOREIGN KEY ("episode_id") REFERENCES "public"."episodes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "shots" ADD CONSTRAINT "shots_scene_asset_id_assets_id_fk" FOREIGN KEY ("scene_asset_id") REFERENCES "public"."assets"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "shots" ADD CONSTRAINT "shots_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "usage_ledger" ADD CONSTRAINT "usage_ledger_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "usage_ledger" ADD CONSTRAINT "usage_ledger_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "usage_ledger" ADD CONSTRAINT "usage_ledger_job_id_generation_jobs_id_fk" FOREIGN KEY ("job_id") REFERENCES "public"."generation_jobs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "workspaces" ADD CONSTRAINT "workspaces_owner_id_users_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "asset_versions_asset_version_unique" ON "asset_versions" USING btree ("asset_id","version");--> statement-breakpoint
|
||||
CREATE INDEX "asset_versions_current_idx" ON "asset_versions" USING btree ("asset_id","is_current");--> statement-breakpoint
|
||||
CREATE INDEX "assets_project_type_idx" ON "assets" USING btree ("project_id","type");--> statement-breakpoint
|
||||
CREATE INDEX "assets_project_status_idx" ON "assets" USING btree ("project_id","status");--> statement-breakpoint
|
||||
CREATE INDEX "audit_logs_workspace_time_idx" ON "audit_logs" USING btree ("workspace_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "audit_logs_actor_idx" ON "audit_logs" USING btree ("actor_id");--> statement-breakpoint
|
||||
CREATE INDEX "deliveries_render_idx" ON "deliveries" USING btree ("render_id");--> statement-breakpoint
|
||||
CREATE INDEX "deliveries_status_idx" ON "deliveries" USING btree ("status");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "episodes_project_number_unique" ON "episodes" USING btree ("project_id","episode_number");--> statement-breakpoint
|
||||
CREATE INDEX "episodes_project_idx" ON "episodes" USING btree ("project_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "generation_jobs_idempotency_unique" ON "generation_jobs" USING btree ("workspace_id","idempotency_key");--> statement-breakpoint
|
||||
CREATE INDEX "generation_jobs_workspace_status_idx" ON "generation_jobs" USING btree ("workspace_id","status");--> statement-breakpoint
|
||||
CREATE INDEX "generation_jobs_project_idx" ON "generation_jobs" USING btree ("project_id");--> statement-breakpoint
|
||||
CREATE INDEX "memberships_user_idx" ON "memberships" USING btree ("user_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "projects_workspace_slug_unique" ON "projects" USING btree ("workspace_id","slug");--> statement-breakpoint
|
||||
CREATE INDEX "projects_workspace_idx" ON "projects" USING btree ("workspace_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "refresh_tokens_hash_unique" ON "refresh_tokens" USING btree ("token_hash");--> statement-breakpoint
|
||||
CREATE INDEX "refresh_tokens_user_idx" ON "refresh_tokens" USING btree ("user_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "renders_episode_version_unique" ON "renders" USING btree ("episode_id","version");--> statement-breakpoint
|
||||
CREATE INDEX "renders_episode_status_idx" ON "renders" USING btree ("episode_id","status");--> statement-breakpoint
|
||||
CREATE INDEX "review_comments_request_idx" ON "review_comments" USING btree ("review_request_id");--> statement-breakpoint
|
||||
CREATE INDEX "review_requests_workspace_status_idx" ON "review_requests" USING btree ("workspace_id","status");--> statement-breakpoint
|
||||
CREATE INDEX "review_requests_target_idx" ON "review_requests" USING btree ("target_type","target_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "script_versions_episode_version_unique" ON "script_versions" USING btree ("episode_id","version");--> statement-breakpoint
|
||||
CREATE INDEX "script_versions_episode_current_idx" ON "script_versions" USING btree ("episode_id","is_current");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "shot_versions_shot_version_unique" ON "shot_versions" USING btree ("shot_id","version");--> statement-breakpoint
|
||||
CREATE INDEX "shot_versions_current_idx" ON "shot_versions" USING btree ("shot_id","is_current");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "shots_episode_number_unique" ON "shots" USING btree ("episode_id","shot_number");--> statement-breakpoint
|
||||
CREATE INDEX "shots_episode_sort_idx" ON "shots" USING btree ("episode_id","sort_order");--> statement-breakpoint
|
||||
CREATE INDEX "usage_ledger_workspace_time_idx" ON "usage_ledger" USING btree ("workspace_id","occurred_at");--> statement-breakpoint
|
||||
CREATE INDEX "usage_ledger_job_idx" ON "usage_ledger" USING btree ("job_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "users_email_unique" ON "users" USING btree ("email");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "workspaces_slug_unique" ON "workspaces" USING btree ("slug");--> statement-breakpoint
|
||||
CREATE INDEX "workspaces_owner_idx" ON "workspaces" USING btree ("owner_id");
|
||||
1
server/drizzle/0001_perfect_gravity.sql
Normal file
1
server/drizzle/0001_perfect_gravity.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TYPE "public"."job_type" ADD VALUE 'PIPELINE_HEALTHCHECK' BEFORE 'SCRIPT_GENERATE';
|
||||
1
server/drizzle/0002_yielding_spencer_smythe.sql
Normal file
1
server/drizzle/0002_yielding_spencer_smythe.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TYPE "public"."asset_type" ADD VALUE 'SHOT';
|
||||
1
server/drizzle/0003_hard_norrin_radd.sql
Normal file
1
server/drizzle/0003_hard_norrin_radd.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TYPE "public"."job_type" ADD VALUE 'STORYBOARD_GENERATE' BEFORE 'ASSET_GENERATE';
|
||||
1
server/drizzle/0004_goofy_karnak.sql
Normal file
1
server/drizzle/0004_goofy_karnak.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "generation_jobs" ADD COLUMN "estimated_credits" numeric(20, 4) DEFAULT '0' NOT NULL;
|
||||
21
server/drizzle/0005_brave_betty_ross.sql
Normal file
21
server/drizzle/0005_brave_betty_ross.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
CREATE TABLE "workspace_invitations" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"email" varchar(320) NOT NULL,
|
||||
"role" "membership_role" DEFAULT 'VIEWER' NOT NULL,
|
||||
"token_hash" text NOT NULL,
|
||||
"expires_at" timestamp with time zone NOT NULL,
|
||||
"accepted_at" timestamp with time zone,
|
||||
"accepted_by_id" uuid,
|
||||
"revoked_at" timestamp with time zone,
|
||||
"invited_by_id" uuid 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 "workspace_invitations" ADD CONSTRAINT "workspace_invitations_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "workspace_invitations" ADD CONSTRAINT "workspace_invitations_accepted_by_id_users_id_fk" FOREIGN KEY ("accepted_by_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "workspace_invitations" ADD CONSTRAINT "workspace_invitations_invited_by_id_users_id_fk" FOREIGN KEY ("invited_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "workspace_invitations_token_hash_unique" ON "workspace_invitations" USING btree ("token_hash");--> statement-breakpoint
|
||||
CREATE INDEX "workspace_invitations_workspace_email_idx" ON "workspace_invitations" USING btree ("workspace_id","email");--> statement-breakpoint
|
||||
CREATE INDEX "workspace_invitations_workspace_created_idx" ON "workspace_invitations" USING btree ("workspace_id","created_at");
|
||||
24
server/drizzle/0006_wooden_texas_twister.sql
Normal file
24
server/drizzle/0006_wooden_texas_twister.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
CREATE TYPE "public"."production_run_status" AS ENUM('QUEUED', 'RUNNING', 'SUCCEEDED', 'FAILED', 'CANCELLED');--> statement-breakpoint
|
||||
CREATE TABLE "production_runs" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"episode_id" uuid NOT NULL,
|
||||
"render_id" uuid NOT NULL,
|
||||
"status" "production_run_status" DEFAULT 'QUEUED' NOT NULL,
|
||||
"settings" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"total_jobs" integer NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"started_at" timestamp with time zone,
|
||||
"completed_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
|
||||
ALTER TABLE "generation_jobs" ADD COLUMN "production_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "production_runs" ADD CONSTRAINT "production_runs_episode_id_episodes_id_fk" FOREIGN KEY ("episode_id") REFERENCES "public"."episodes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "production_runs" ADD CONSTRAINT "production_runs_render_id_renders_id_fk" FOREIGN KEY ("render_id") REFERENCES "public"."renders"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "production_runs" ADD CONSTRAINT "production_runs_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "production_runs_render_unique" ON "production_runs" USING btree ("render_id");--> statement-breakpoint
|
||||
CREATE INDEX "production_runs_episode_status_idx" ON "production_runs" USING btree ("episode_id","status");--> statement-breakpoint
|
||||
CREATE INDEX "production_runs_episode_created_idx" ON "production_runs" USING btree ("episode_id","created_at");--> statement-breakpoint
|
||||
ALTER TABLE "generation_jobs" ADD CONSTRAINT "generation_jobs_production_run_id_production_runs_id_fk" FOREIGN KEY ("production_run_id") REFERENCES "public"."production_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "generation_jobs_production_run_idx" ON "generation_jobs" USING btree ("production_run_id");
|
||||
15
server/drizzle/0007_sudden_roland_deschain.sql
Normal file
15
server/drizzle/0007_sudden_roland_deschain.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE TYPE "public"."account_token_type" AS ENUM('EMAIL_VERIFICATION', 'PASSWORD_RESET');--> statement-breakpoint
|
||||
CREATE TABLE "account_action_tokens" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"type" "account_token_type" NOT NULL,
|
||||
"token_hash" text NOT NULL,
|
||||
"expires_at" timestamp with time zone NOT NULL,
|
||||
"consumed_at" timestamp with time zone,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "account_action_tokens" ADD CONSTRAINT "account_action_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "account_action_tokens_hash_unique" ON "account_action_tokens" USING btree ("token_hash");--> statement-breakpoint
|
||||
CREATE INDEX "account_action_tokens_user_type_idx" ON "account_action_tokens" USING btree ("user_id","type");--> statement-breakpoint
|
||||
CREATE INDEX "account_action_tokens_expiry_idx" ON "account_action_tokens" USING btree ("expires_at");
|
||||
4
server/drizzle/0008_red_trish_tilby.sql
Normal file
4
server/drizzle/0008_red_trish_tilby.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
ALTER TYPE "public"."delivery_status" ADD VALUE 'CANCELLED';--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD COLUMN "job_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD CONSTRAINT "deliveries_job_id_generation_jobs_id_fk" FOREIGN KEY ("job_id") REFERENCES "public"."generation_jobs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "deliveries_job_idx" ON "deliveries" USING btree ("job_id");
|
||||
34
server/drizzle/0009_chilly_mockingbird.sql
Normal file
34
server/drizzle/0009_chilly_mockingbird.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE "billing_subscriptions" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"provider" varchar(32) DEFAULT 'stripe' NOT NULL,
|
||||
"customer_id" varchar(255) NOT NULL,
|
||||
"subscription_id" varchar(255),
|
||||
"price_id" varchar(255),
|
||||
"plan" varchar(32),
|
||||
"status" varchar(48) DEFAULT 'no_subscription' NOT NULL,
|
||||
"current_period_end" timestamp with time zone,
|
||||
"cancel_at_period_end" boolean DEFAULT false NOT NULL,
|
||||
"last_event_created_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 "billing_webhook_events" (
|
||||
"event_id" varchar(255) PRIMARY KEY NOT NULL,
|
||||
"provider" varchar(32) DEFAULT 'stripe' NOT NULL,
|
||||
"event_type" varchar(160) NOT NULL,
|
||||
"livemode" boolean DEFAULT false NOT NULL,
|
||||
"workspace_id" uuid,
|
||||
"provider_created_at" timestamp with time zone NOT NULL,
|
||||
"processed_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "billing_subscriptions" ADD CONSTRAINT "billing_subscriptions_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "billing_webhook_events" ADD CONSTRAINT "billing_webhook_events_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "billing_subscriptions_workspace_unique" ON "billing_subscriptions" USING btree ("workspace_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "billing_subscriptions_customer_unique" ON "billing_subscriptions" USING btree ("customer_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "billing_subscriptions_subscription_unique" ON "billing_subscriptions" USING btree ("subscription_id");--> statement-breakpoint
|
||||
CREATE INDEX "billing_subscriptions_status_idx" ON "billing_subscriptions" USING btree ("status");--> statement-breakpoint
|
||||
CREATE INDEX "billing_webhook_events_workspace_idx" ON "billing_webhook_events" USING btree ("workspace_id","processed_at");--> statement-breakpoint
|
||||
CREATE INDEX "billing_webhook_events_type_idx" ON "billing_webhook_events" USING btree ("event_type");
|
||||
3
server/drizzle/0010_sharp_odin.sql
Normal file
3
server/drizzle/0010_sharp_odin.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE "renders" ADD COLUMN "subtitle_srt_key" text;--> statement-breakpoint
|
||||
ALTER TABLE "renders" ADD COLUMN "subtitle_vtt_key" text;--> statement-breakpoint
|
||||
ALTER TABLE "renders" ADD COLUMN "source_manifest" jsonb;
|
||||
25
server/drizzle/0011_futuristic_stature.sql
Normal file
25
server/drizzle/0011_futuristic_stature.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
CREATE TYPE "public"."notification_tone" AS ENUM('INFO', 'SUCCESS', 'WARNING', 'ERROR');--> statement-breakpoint
|
||||
CREATE TABLE "notifications" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"kind" varchar(80) NOT NULL,
|
||||
"tone" "notification_tone" DEFAULT 'INFO' NOT NULL,
|
||||
"title" varchar(240) NOT NULL,
|
||||
"body" text DEFAULT '' NOT NULL,
|
||||
"page" varchar(48) NOT NULL,
|
||||
"resource_type" varchar(80),
|
||||
"resource_id" uuid,
|
||||
"dedupe_key" varchar(255) NOT NULL,
|
||||
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"read_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
|
||||
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "notifications_user_dedupe_unique" ON "notifications" USING btree ("user_id","dedupe_key");--> statement-breakpoint
|
||||
CREATE INDEX "notifications_user_created_idx" ON "notifications" USING btree ("user_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "notifications_user_unread_idx" ON "notifications" USING btree ("user_id","read_at","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "notifications_workspace_created_idx" ON "notifications" USING btree ("workspace_id","created_at");
|
||||
62
server/drizzle/0012_warm_old_lace.sql
Normal file
62
server/drizzle/0012_warm_old_lace.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
CREATE TYPE "public"."publishing_channel_status" AS ENUM('CONNECTED', 'EXPIRED', 'REVOKED', 'ERROR');--> statement-breakpoint
|
||||
CREATE TABLE "publishing_channel_accounts" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"platform" varchar(32) NOT NULL,
|
||||
"external_account_id" varchar(255) NOT NULL,
|
||||
"display_name" varchar(180) NOT NULL,
|
||||
"avatar_url" text,
|
||||
"status" "publishing_channel_status" DEFAULT 'CONNECTED' NOT NULL,
|
||||
"access_token_ciphertext" text,
|
||||
"refresh_token_ciphertext" text,
|
||||
"token_expires_at" timestamp with time zone,
|
||||
"scopes" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"connected_by_id" uuid NOT NULL,
|
||||
"last_verified_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"error_code" varchar(100),
|
||||
"error_message" text,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "publishing_oauth_states" (
|
||||
"state_hash" varchar(64) PRIMARY KEY NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"platform" varchar(32) NOT NULL,
|
||||
"code_verifier_ciphertext" text,
|
||||
"return_path" text DEFAULT '/?publishing=connected' NOT NULL,
|
||||
"created_by_id" uuid NOT NULL,
|
||||
"expires_at" timestamp with time zone NOT NULL,
|
||||
"consumed_at" timestamp with time zone,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "publishing_webhook_events" (
|
||||
"event_key" varchar(320) PRIMARY KEY NOT NULL,
|
||||
"event_id" varchar(255) NOT NULL,
|
||||
"platform" varchar(32) NOT NULL,
|
||||
"delivery_id" uuid,
|
||||
"status" varchar(32) NOT NULL,
|
||||
"provider_occurred_at" timestamp with time zone NOT NULL,
|
||||
"payload" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"applied" boolean DEFAULT false NOT NULL,
|
||||
"processed_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD COLUMN "channel_account_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD COLUMN "last_provider_event_at" timestamp with time zone;--> statement-breakpoint
|
||||
ALTER TABLE "publishing_channel_accounts" ADD CONSTRAINT "publishing_channel_accounts_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "publishing_channel_accounts" ADD CONSTRAINT "publishing_channel_accounts_connected_by_id_users_id_fk" FOREIGN KEY ("connected_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "publishing_oauth_states" ADD CONSTRAINT "publishing_oauth_states_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "publishing_oauth_states" ADD CONSTRAINT "publishing_oauth_states_created_by_id_users_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "publishing_webhook_events" ADD CONSTRAINT "publishing_webhook_events_delivery_id_deliveries_id_fk" FOREIGN KEY ("delivery_id") REFERENCES "public"."deliveries"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "publishing_channel_accounts_external_unique" ON "publishing_channel_accounts" USING btree ("workspace_id","platform","external_account_id");--> statement-breakpoint
|
||||
CREATE INDEX "publishing_channel_accounts_workspace_idx" ON "publishing_channel_accounts" USING btree ("workspace_id","platform");--> statement-breakpoint
|
||||
CREATE INDEX "publishing_channel_accounts_status_idx" ON "publishing_channel_accounts" USING btree ("workspace_id","status");--> statement-breakpoint
|
||||
CREATE INDEX "publishing_oauth_states_expiry_idx" ON "publishing_oauth_states" USING btree ("expires_at");--> statement-breakpoint
|
||||
CREATE INDEX "publishing_oauth_states_workspace_idx" ON "publishing_oauth_states" USING btree ("workspace_id","platform");--> statement-breakpoint
|
||||
CREATE INDEX "publishing_webhook_events_delivery_idx" ON "publishing_webhook_events" USING btree ("delivery_id","provider_occurred_at");--> statement-breakpoint
|
||||
CREATE INDEX "publishing_webhook_events_platform_idx" ON "publishing_webhook_events" USING btree ("platform","processed_at");--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD CONSTRAINT "deliveries_channel_account_id_publishing_channel_accounts_id_fk" FOREIGN KEY ("channel_account_id") REFERENCES "public"."publishing_channel_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "deliveries_channel_account_idx" ON "deliveries" USING btree ("channel_account_id");
|
||||
3
server/drizzle/0013_lethal_giant_man.sql
Normal file
3
server/drizzle/0013_lethal_giant_man.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE "publishing_webhook_events" ADD COLUMN "workspace_id" uuid NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "publishing_webhook_events" ADD CONSTRAINT "publishing_webhook_events_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "publishing_webhook_events_workspace_idx" ON "publishing_webhook_events" USING btree ("workspace_id","processed_at");
|
||||
3
server/drizzle/0014_heavy_retro_girl.sql
Normal file
3
server/drizzle/0014_heavy_retro_girl.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE "deliveries" DROP CONSTRAINT "deliveries_channel_account_id_publishing_channel_accounts_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD CONSTRAINT "deliveries_channel_account_id_publishing_channel_accounts_id_fk" FOREIGN KEY ("channel_account_id") REFERENCES "public"."publishing_channel_accounts"("id") ON DELETE set null ON UPDATE no action;
|
||||
3
server/drizzle/0015_reflective_true_believers.sql
Normal file
3
server/drizzle/0015_reflective_true_believers.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE "deliveries" DROP CONSTRAINT "deliveries_channel_account_id_publishing_channel_accounts_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "deliveries" ADD CONSTRAINT "deliveries_channel_account_id_publishing_channel_accounts_id_fk" FOREIGN KEY ("channel_account_id") REFERENCES "public"."publishing_channel_accounts"("id") ON DELETE cascade ON UPDATE no action;
|
||||
20
server/drizzle/0016_amused_longshot.sql
Normal file
20
server/drizzle/0016_amused_longshot.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE "provider_verifications" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"workspace_id" uuid NOT NULL,
|
||||
"provider" varchar(32) NOT NULL,
|
||||
"status" varchar(32) NOT NULL,
|
||||
"configuration_fingerprint" varchar(64) NOT NULL,
|
||||
"checked_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"latency_ms" integer,
|
||||
"error_code" varchar(80),
|
||||
"message" text,
|
||||
"details" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"checked_by_id" uuid 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 "provider_verifications" ADD CONSTRAINT "provider_verifications_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "provider_verifications" ADD CONSTRAINT "provider_verifications_checked_by_id_users_id_fk" FOREIGN KEY ("checked_by_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "provider_verifications_workspace_provider_unique" ON "provider_verifications" USING btree ("workspace_id","provider");--> statement-breakpoint
|
||||
CREATE INDEX "provider_verifications_workspace_status_idx" ON "provider_verifications" USING btree ("workspace_id","status");
|
||||
2980
server/drizzle/meta/0000_snapshot.json
Normal file
2980
server/drizzle/meta/0000_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2981
server/drizzle/meta/0001_snapshot.json
Normal file
2981
server/drizzle/meta/0001_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2982
server/drizzle/meta/0002_snapshot.json
Normal file
2982
server/drizzle/meta/0002_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2983
server/drizzle/meta/0003_snapshot.json
Normal file
2983
server/drizzle/meta/0003_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2990
server/drizzle/meta/0004_snapshot.json
Normal file
2990
server/drizzle/meta/0004_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
3178
server/drizzle/meta/0005_snapshot.json
Normal file
3178
server/drizzle/meta/0005_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
3406
server/drizzle/meta/0006_snapshot.json
Normal file
3406
server/drizzle/meta/0006_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
3538
server/drizzle/meta/0007_snapshot.json
Normal file
3538
server/drizzle/meta/0007_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
3573
server/drizzle/meta/0008_snapshot.json
Normal file
3573
server/drizzle/meta/0008_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
3854
server/drizzle/meta/0009_snapshot.json
Normal file
3854
server/drizzle/meta/0009_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
3872
server/drizzle/meta/0010_snapshot.json
Normal file
3872
server/drizzle/meta/0010_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
4110
server/drizzle/meta/0011_snapshot.json
Normal file
4110
server/drizzle/meta/0011_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
4646
server/drizzle/meta/0012_snapshot.json
Normal file
4646
server/drizzle/meta/0012_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
4686
server/drizzle/meta/0013_snapshot.json
Normal file
4686
server/drizzle/meta/0013_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
4686
server/drizzle/meta/0014_snapshot.json
Normal file
4686
server/drizzle/meta/0014_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
4686
server/drizzle/meta/0015_snapshot.json
Normal file
4686
server/drizzle/meta/0015_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
4852
server/drizzle/meta/0016_snapshot.json
Normal file
4852
server/drizzle/meta/0016_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
125
server/drizzle/meta/_journal.json
Normal file
125
server/drizzle/meta/_journal.json
Normal file
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1785398872080,
|
||||
"tag": "0000_last_spectrum",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "7",
|
||||
"when": 1785400342760,
|
||||
"tag": "0001_perfect_gravity",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "7",
|
||||
"when": 1785401841259,
|
||||
"tag": "0002_yielding_spencer_smythe",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "7",
|
||||
"when": 1785404103710,
|
||||
"tag": "0003_hard_norrin_radd",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "7",
|
||||
"when": 1785405889215,
|
||||
"tag": "0004_goofy_karnak",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "7",
|
||||
"when": 1785431751467,
|
||||
"tag": "0005_brave_betty_ross",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "7",
|
||||
"when": 1785432812502,
|
||||
"tag": "0006_wooden_texas_twister",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "7",
|
||||
"when": 1785434191972,
|
||||
"tag": "0007_sudden_roland_deschain",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 8,
|
||||
"version": "7",
|
||||
"when": 1785435268450,
|
||||
"tag": "0008_red_trish_tilby",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "7",
|
||||
"when": 1785437272781,
|
||||
"tag": "0009_chilly_mockingbird",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 10,
|
||||
"version": "7",
|
||||
"when": 1785439338694,
|
||||
"tag": "0010_sharp_odin",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 11,
|
||||
"version": "7",
|
||||
"when": 1785446641562,
|
||||
"tag": "0011_futuristic_stature",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "7",
|
||||
"when": 1785450378611,
|
||||
"tag": "0012_warm_old_lace",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 13,
|
||||
"version": "7",
|
||||
"when": 1785450438724,
|
||||
"tag": "0013_lethal_giant_man",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 14,
|
||||
"version": "7",
|
||||
"when": 1785450621103,
|
||||
"tag": "0014_heavy_retro_girl",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 15,
|
||||
"version": "7",
|
||||
"when": 1785450684178,
|
||||
"tag": "0015_reflective_true_believers",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 16,
|
||||
"version": "7",
|
||||
"when": 1785456376158,
|
||||
"tag": "0016_amused_longshot",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user