mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(backup): bring every relation link back from a portable restore
A portable file carries no id for a medication or a lab result, so the restore mints fresh ones and the links that named the old ids were dropped as having no end. Carry the source id as ref on both entries and re-point the links through an old-to-new map on restore.
This commit is contained in:
1 parent
c508ce61e3
commit
1a7050d95d
6 files changed
+297
-5
No files matched your search
@@ -392,6 +392,10 @@ const customMedicationCategorySchema = z
|
||||
const medicationSchema = z
|
||||
.object({
|
||||
id: z.string().min(1).optional(),
|
||||
// The source row's id in a portable file, which carries no `id`: the
|
||||
// relation links name the medication by it, and the restore re-points
|
||||
// them at the row it writes (`relation-links-backup.ts`).
|
||||
ref: z.string().min(1).optional(),
|
||||
name: z.string().min(1),
|
||||
dose: z.string(),
|
||||
treatmentClass: z.enum(MedicationCategory).optional(),
|
||||
@@ -1126,6 +1130,8 @@ const appSettingsBackupSchema = z
|
||||
const labResultBackupSchema = z
|
||||
.object({
|
||||
id: z.string().min(1).optional(),
|
||||
// The source row's id in a portable file, as on a medication.
|
||||
ref: z.string().min(1).optional(),
|
||||
panel: z.string().nullable().optional(),
|
||||
analyte: z.string().min(1),
|
||||
value: z.number().nullable().optional(),
|
||||
|
||||
Reference in new issue
Block a user