mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
fix(backup): carry each medication's category through backup and restore
The clinical category a person picks for a medication lives in a side table created at runtime, outside the schema. The backup builder and the restore only walk schema models, so no backup ever carried it: after a restore every medication read as "Other". Both backup formats now carry the category inside its medication, and the restore writes it back in the same transaction as the medication. A file from before this change restores as before; a category this server does not know reads as Other instead of refusing the file. The backup plan gains a list for tables created with raw SQL, and a check that every such table in the source either maps to a schema model or has a verdict there, so the next one cannot drop out of backups unnoticed.
This commit is contained in:
1 parent
e94e9b94a8
commit
6f37cbdb23
10 files changed
+215
-5
No files matched your search
@@ -12,6 +12,13 @@ const mocks = vi.hoisted(() => ({
|
||||
buildRecordsBackupSection: vi.fn(),
|
||||
}));
|
||||
|
||||
// The category side table is raw SQL on the shared client; the round trip
|
||||
// through it is proven in tests/integration/backup-round-trip.test.ts.
|
||||
vi.mock("@/lib/medication-category", () => ({
|
||||
ensureMedicationCategoryTable: vi.fn(async () => {}),
|
||||
getMedicationCategories: vi.fn(async () => ({})),
|
||||
setMedicationCategory: vi.fn(async () => "OTHER"),
|
||||
}));
|
||||
vi.mock("@/lib/export/paged-measurements", () => ({
|
||||
iterateMeasurementPages: mocks.iterateMeasurementPages,
|
||||
}));
|
||||
|
||||
@@ -31,6 +31,13 @@ const mocks = vi.hoisted(() => ({
|
||||
transaction: vi.fn(),
|
||||
}));
|
||||
|
||||
// The category side table is raw SQL on the shared client; the round trip
|
||||
// through it is proven in tests/integration/backup-round-trip.test.ts.
|
||||
vi.mock("@/lib/medication-category", () => ({
|
||||
ensureMedicationCategoryTable: vi.fn(async () => {}),
|
||||
getMedicationCategories: vi.fn(async () => ({})),
|
||||
setMedicationCategory: vi.fn(async () => "OTHER"),
|
||||
}));
|
||||
vi.mock("@/lib/db", () => ({
|
||||
prisma: {
|
||||
dataBackup: { findUnique: vi.fn() },
|
||||
|
||||
Reference in new issue
Block a user