feat(transactions): ek bağlama, hesap ekstresi ve mutabakat servisi, 004 migration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { getAuth } from "@/lib/auth";
|
||||
import { getDb } from "@/lib/db/mongo";
|
||||
import { connectMongoose } from "@/lib/db/mongoose";
|
||||
import { env } from "@/lib/env";
|
||||
import { getStorage } from "@/lib/storage";
|
||||
import { installDefaultCategories } from "@/features/categories/service";
|
||||
import { AccountModel } from "@/models/account";
|
||||
import { HouseholdModel } from "@/models/household";
|
||||
@@ -53,6 +54,10 @@ const DOMAIN_COLLECTIONS = [
|
||||
"auditLogs",
|
||||
"categories",
|
||||
"accounts",
|
||||
"transactions",
|
||||
"payees",
|
||||
"attachments",
|
||||
"reconciliations",
|
||||
];
|
||||
|
||||
type AuthApi = ReturnType<typeof getAuth>["api"];
|
||||
@@ -107,6 +112,14 @@ export async function runSeed({
|
||||
};
|
||||
|
||||
if (reset) {
|
||||
// Ek dosyaların diskteki kopyaları da silinsin (yetim dosya kalmasın).
|
||||
const storage = getStorage();
|
||||
for await (const a of db
|
||||
.collection("attachments")
|
||||
.find({}, { projection: { storageKey: 1, thumbKey: 1 } })) {
|
||||
await storage.delete(String(a.storageKey));
|
||||
if (a.thumbKey) await storage.delete(String(a.thumbKey));
|
||||
}
|
||||
for (const name of [...AUTH_COLLECTIONS, ...DOMAIN_COLLECTIONS]) {
|
||||
await db.collection(name).deleteMany({});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user