import { AttachmentModel } from "@/models/attachment"; import { ReconciliationModel } from "@/models/reconciliation"; import type { Migration } from "./types"; export const migration: Migration = { name: "004-attachments-reconciliation", description: "attachments ve reconciliations index'leri; işlemlerde mutabakat alanları", async up(db) { await AttachmentModel.createIndexes(); await ReconciliationModel.createIndexes(); const tx = db.collection("transactions"); // reconciledAt (hiç kullanılmadı) → hesap bazında reconciledAccountIds. await tx.updateMany({ reconciledAt: { $exists: true } }, { $unset: { reconciledAt: "" } }); await tx.updateMany( { reconciledAccountIds: { $exists: false } }, { $set: { reconciledAccountIds: [] } }, ); await tx.updateMany({ isAdjustment: { $exists: false } }, { $set: { isAdjustment: false } }); }, };