ALTER TABLE "Payment" ADD COLUMN "financialAccountId" TEXT; ALTER TABLE "Cheque" ADD COLUMN "financialAccountId" TEXT; ALTER TABLE "FinancialMovement" ADD COLUMN "paymentId" TEXT; ALTER TABLE "FinancialMovement" ADD COLUMN "chequeId" TEXT; CREATE INDEX "FinancialMovement_paymentId_idx" ON "FinancialMovement"("paymentId"); CREATE INDEX "FinancialMovement_chequeId_idx" ON "FinancialMovement"("chequeId"); CREATE TABLE "FinancialAuditLog" ( "id" TEXT NOT NULL, "organizationId" TEXT NOT NULL, "entityType" TEXT NOT NULL, "entityId" TEXT NOT NULL, "action" TEXT NOT NULL, "before" JSONB, "after" JSONB, "actorUserId" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "FinancialAuditLog_pkey" PRIMARY KEY ("id") ); CREATE INDEX "FinancialAuditLog_organizationId_entityType_entityId_createdAt_idx" ON "FinancialAuditLog"("organizationId", "entityType", "entityId", "createdAt"); CREATE TABLE "FinancialAttachment" ( "id" TEXT NOT NULL, "organizationId" TEXT NOT NULL, "documentId" TEXT NOT NULL, "fileName" TEXT NOT NULL, "mimeType" TEXT NOT NULL, "storageKey" TEXT NOT NULL, "createdById" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "FinancialAttachment_pkey" PRIMARY KEY ("id") ); CREATE INDEX "FinancialAttachment_documentId_idx" ON "FinancialAttachment"("documentId"); ALTER TABLE "FinancialAuditLog" ADD CONSTRAINT "FinancialAuditLog_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE "FinancialAttachment" ADD CONSTRAINT "FinancialAttachment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE "FinancialAttachment" ADD CONSTRAINT "FinancialAttachment_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "FinancialDocument"("id") ON DELETE CASCADE ON UPDATE CASCADE;