ALTER TABLE "documents" ADD COLUMN "project_id" integer NOT NULL;--> statement-breakpoint ALTER TABLE "documents" ADD CONSTRAINT "documents_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "unique_project_doc_status" ON "documents" USING btree ("project_id","doc_number","status");--> statement-breakpoint CREATE UNIQUE INDEX "unique_project_vendor_doc" ON "documents" USING btree ("project_id","vendor_doc_number") WHERE "documents"."vendor_doc_number" IS NOT NULL;--> statement-breakpoint CREATE UNIQUE INDEX "unique_external_doc_project" ON "documents" USING btree ("project_id","external_document_id","external_system_type") WHERE "documents"."external_document_id" IS NOT NULL;