2e2e33233f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
902 B
TypeScript
21 lines
902 B
TypeScript
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 } });
|
||
},
|
||
};
|