Files
PaperClipAI/packages/db/src/migrations/0430_regular_red_skull.sql
T
DottaandPaperclip 0eaabe5c0b refactor(accounting): remove company serialization from paid settlement (#18917)
Settle paid operations through operation-scoped transactions. Preserve exact ledger evidence and replay while moving aggregate budget decisions to durable deferred work.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-04 07:29:28 -06:00

13 lines
1.2 KiB
SQL

CREATE TABLE IF NOT EXISTS "budget_evaluation_work" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"company_id" uuid NOT NULL,
"agent_id" uuid,
"project_id" uuid,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "budget_policies" ADD COLUMN IF NOT EXISTS "evaluation_version" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
DO $$ BEGIN ALTER TABLE "budget_evaluation_work" ADD CONSTRAINT "budget_evaluation_work_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN NULL; END $$;--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "budget_evaluation_work_company_pending_idx" ON "budget_evaluation_work" USING btree ("company_id","created_at","id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "budget_evaluation_work_agent_pending_idx" ON "budget_evaluation_work" USING btree ("company_id","agent_id","created_at");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "budget_evaluation_work_project_pending_idx" ON "budget_evaluation_work" USING btree ("company_id","project_id","created_at");