Files
PaperClipAI/packages/db/src/migrations/0421_bright_skaar.sql
T
DottaandPaperclip 5e4cc01073 feat(workspaces): keep remote files off the webserver disk (#18403)
Keep native sandbox workspace files independent of the webserver disk. Use encrypted saved versions and Postgres ownership so a replacement server can recover files and continue work. Enable the path by default for new eligible workspaces when durable storage is configured.

Preserve explicit opt-outs and existing host workspaces. Include safe snapshot repair, Files access, import, migration and retention. Bound saved-Files resources, preserve imported Git recovery, reject unfinished Git operations, publish immutable concurrent captures, and verify permanent object-version deletion.

Validated 471 targeted local controls, build/typechecks, all 40 CI partitions, fresh Greptile 5/5 and security review. The PR records original failed attempts and scoped retries.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-31 14:54:01 -05:00

27 lines
1.5 KiB
SQL

CREATE TABLE IF NOT EXISTS "execution_workspace_snapshots" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"company_id" uuid NOT NULL,
"execution_workspace_id" uuid NOT NULL,
"source_operation_id" uuid NOT NULL,
"source_run_id" uuid,
"parent_snapshot_id" uuid,
"generation" integer NOT NULL,
"epoch" integer NOT NULL,
"status" text DEFAULT 'pending' NOT NULL,
"format" text DEFAULT 'paperclip.remote-workspace-archive.v1' NOT NULL,
"object_key" text,
"sha256" text,
"byte_size" bigint,
"key" jsonb,
"manifest_digest" text,
"metadata" jsonb,
"delete_after" timestamp with time zone,
"last_error" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "execution_workspace_snapshots_operation_uniq" ON "execution_workspace_snapshots" USING btree ("company_id","execution_workspace_id","source_operation_id");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "execution_workspace_snapshots_generation_uniq" ON "execution_workspace_snapshots" USING btree ("company_id","execution_workspace_id","generation");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "execution_workspace_snapshots_workspace_idx" ON "execution_workspace_snapshots" USING btree ("company_id","execution_workspace_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "execution_workspace_snapshots_cleanup_idx" ON "execution_workspace_snapshots" USING btree ("status","delete_after");