feat(backup): include digests and digest_images in backup/restore and sweep
This commit is contained in:
+23
-3
@@ -19,14 +19,14 @@ const BACKUP_TABLES = [
|
||||
'lesson_reports', 'lesson_report_versions', 'audit_log', 'notifications',
|
||||
'notification_reads', 'banned_ips', 'chat_threads', 'chat_messages', 'chat_attachments',
|
||||
'short_messages', 'feedbacks', 'bookmarks', 'student_face_refs', 'photo_faces',
|
||||
'student_work_marks', 'achievement_types', 'student_achievements', 'doc_sections', 'doc_articles', 'doc_images', 'doc_files', 'sidebar_items',
|
||||
'student_work_marks', 'achievement_types', 'student_achievements', 'doc_sections', 'doc_articles', 'doc_images', 'doc_files', 'sidebar_items', 'digests', 'digest_images',
|
||||
];
|
||||
const BACKUP_SEQUENCE_TABLES = [
|
||||
'groups', 'students', 'entries', 'project_files', 'branches', 'users', 'user_notes', 'group_photos',
|
||||
'entry_photos', 'modules', 'student_photos', 'share_links', 'photo_jobs', 'lesson_reports',
|
||||
'lesson_report_versions', 'audit_log', 'notifications', 'chat_threads', 'chat_messages',
|
||||
'chat_attachments', 'short_messages', 'feedbacks', 'bookmarks', 'student_face_refs', 'photo_faces',
|
||||
'student_work_marks', 'achievement_types', 'student_achievements', 'doc_sections', 'doc_articles', 'doc_images', 'doc_files', 'sidebar_items',
|
||||
'student_work_marks', 'achievement_types', 'student_achievements', 'doc_sections', 'doc_articles', 'doc_images', 'doc_files', 'sidebar_items', 'digests', 'digest_images',
|
||||
];
|
||||
|
||||
function isSupportedBackupVersion(data) {
|
||||
@@ -702,6 +702,26 @@ function normalizeRestoreData(data) {
|
||||
uploaded_by: x.uploaded_by == null ? null : reqInt(x.uploaded_by),
|
||||
created_at: optTs(x.created_at),
|
||||
})).filter(x => x.path);
|
||||
const digests = (data.digests || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
title: reqStr(x.title, 200),
|
||||
body: reqStr(x.body, 5000),
|
||||
author_id: x.author_id == null ? null : reqInt(x.author_id),
|
||||
is_pinned: x.is_pinned === true,
|
||||
preview_path: optUploadPath(x.preview_path, 255) || null,
|
||||
post_at: optTs(x.post_at),
|
||||
hide_at: optTs(x.hide_at),
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
}));
|
||||
const digestImages = (data.digest_images || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
digest_id: reqInt(x.digest_id),
|
||||
path: optUploadPath(x.path, 300) || '',
|
||||
name: optText(x.name, 300) || '',
|
||||
size: optInt(x.size, 0, Number.MAX_SAFE_INTEGER) || 0,
|
||||
created_at: optTs(x.created_at),
|
||||
})).filter(x => x.digest_id && x.path);
|
||||
const sidebarItems = (data.sidebar_items || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
kind: ['item','divider','group'].includes(x.kind) ? x.kind : 'item',
|
||||
@@ -738,7 +758,7 @@ function normalizeRestoreData(data) {
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
})).filter(x => x.source_id && x.photo_path);
|
||||
return { groups, students, entries, project_files, settings, branches, users, user_branches, user_settings, user_notes, entry_photos, student_photos, group_photos, share_links, modules, photo_jobs, lesson_reports, lesson_report_versions, audit_log, notifications, notification_reads, banned_ips, chat_threads, chat_messages, chat_attachments, short_messages, feedbacks, bookmarks, achievement_types: achievementTypes, student_achievements: studentAchievements, student_face_refs: faceRefs, photo_faces: faceRows, student_work_marks, doc_sections: docSections, doc_articles: docArticles, doc_images: docImages, doc_files: docFiles, sidebar_items: sidebarItems };
|
||||
return { groups, students, entries, project_files, settings, branches, users, user_branches, user_settings, user_notes, entry_photos, student_photos, group_photos, share_links, modules, photo_jobs, lesson_reports, lesson_report_versions, audit_log, notifications, notification_reads, banned_ips, chat_threads, chat_messages, chat_attachments, short_messages, feedbacks, bookmarks, achievement_types: achievementTypes, student_achievements: studentAchievements, student_face_refs: faceRefs, photo_faces: faceRows, student_work_marks, doc_sections: docSections, doc_articles: docArticles, doc_images: docImages, doc_files: docFiles, sidebar_items: sidebarItems, digests, digest_images: digestImages };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user