29 lines
1.8 KiB
SQL
29 lines
1.8 KiB
SQL
CREATE TABLE "workspace_operations" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"company_id" uuid NOT NULL,
|
|
"execution_workspace_id" uuid,
|
|
"heartbeat_run_id" uuid,
|
|
"phase" text NOT NULL,
|
|
"command" text,
|
|
"cwd" text,
|
|
"status" text DEFAULT 'running' NOT NULL,
|
|
"exit_code" integer,
|
|
"log_store" text,
|
|
"log_ref" text,
|
|
"log_bytes" bigint,
|
|
"log_sha256" text,
|
|
"log_compressed" boolean DEFAULT false NOT NULL,
|
|
"stdout_excerpt" text,
|
|
"stderr_excerpt" text,
|
|
"metadata" jsonb,
|
|
"started_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"finished_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 "workspace_operations" ADD CONSTRAINT "workspace_operations_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "workspace_operations" ADD CONSTRAINT "workspace_operations_execution_workspace_id_execution_workspaces_id_fk" FOREIGN KEY ("execution_workspace_id") REFERENCES "public"."execution_workspaces"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "workspace_operations" ADD CONSTRAINT "workspace_operations_heartbeat_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("heartbeat_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "workspace_operations_company_run_started_idx" ON "workspace_operations" USING btree ("company_id","heartbeat_run_id","started_at");--> statement-breakpoint
|
|
CREATE INDEX "workspace_operations_company_workspace_started_idx" ON "workspace_operations" USING btree ("company_id","execution_workspace_id","started_at"); |