feat(versions): include pin_kind/pin_label in backup export+restore
Both export paths emit pin_kind and pin_label per note_version row. Restore reads them via .get() so backups predating the schema still import cleanly (defaults to None → rolling).
This commit is contained in:
@@ -150,6 +150,8 @@ async def export_full_backup() -> dict:
|
|||||||
"title": nv.title,
|
"title": nv.title,
|
||||||
"body": nv.body,
|
"body": nv.body,
|
||||||
"tags": nv.tags or [],
|
"tags": nv.tags or [],
|
||||||
|
"pin_kind": nv.pin_kind,
|
||||||
|
"pin_label": nv.pin_label,
|
||||||
"created_at": nv.created_at.isoformat(),
|
"created_at": nv.created_at.isoformat(),
|
||||||
}
|
}
|
||||||
for nv in note_versions
|
for nv in note_versions
|
||||||
@@ -314,6 +316,8 @@ async def export_user_backup(user_id: int) -> dict:
|
|||||||
"title": nv.title,
|
"title": nv.title,
|
||||||
"body": nv.body,
|
"body": nv.body,
|
||||||
"tags": nv.tags or [],
|
"tags": nv.tags or [],
|
||||||
|
"pin_kind": nv.pin_kind,
|
||||||
|
"pin_label": nv.pin_label,
|
||||||
"created_at": nv.created_at.isoformat(),
|
"created_at": nv.created_at.isoformat(),
|
||||||
}
|
}
|
||||||
for nv in note_versions
|
for nv in note_versions
|
||||||
@@ -605,6 +609,8 @@ async def _restore_v2(data: dict) -> dict:
|
|||||||
title=nv_data.get("title", ""),
|
title=nv_data.get("title", ""),
|
||||||
body=nv_data.get("body", ""),
|
body=nv_data.get("body", ""),
|
||||||
tags=nv_data.get("tags", []),
|
tags=nv_data.get("tags", []),
|
||||||
|
pin_kind=nv_data.get("pin_kind"),
|
||||||
|
pin_label=nv_data.get("pin_label"),
|
||||||
created_at=_dt(nv_data.get("created_at")),
|
created_at=_dt(nv_data.get("created_at")),
|
||||||
)
|
)
|
||||||
session.add(nv)
|
session.add(nv)
|
||||||
|
|||||||
Reference in New Issue
Block a user