feat: backup + restore

This commit is contained in:
Vasily Zubarev
2025-03-28 23:36:27 +01:00
parent 61da617f68
commit 54a892ddb0
11 changed files with 340 additions and 63 deletions

46
models/backups.ts Normal file
View File

@@ -0,0 +1,46 @@
import { prisma } from "@/lib/db"
type ModelEntry = {
filename: string
model: any
idField: string
}
// Ordering is important here
export const MODEL_BACKUP: ModelEntry[] = [
{
filename: "settings.json",
model: prisma.setting,
idField: "code",
},
{
filename: "currencies.json",
model: prisma.currency,
idField: "code",
},
{
filename: "categories.json",
model: prisma.category,
idField: "code",
},
{
filename: "projects.json",
model: prisma.project,
idField: "code",
},
{
filename: "fields.json",
model: prisma.field,
idField: "code",
},
{
filename: "files.json",
model: prisma.file,
idField: "id",
},
{
filename: "transactions.json",
model: prisma.transaction,
idField: "id",
},
]