Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(views/geomap): migrate db to new collection type
Elian Doranf5a6dfa629d6
diff --git a/apps/server/src/migrations/0233__migrate_geo_map_to_collection.ts b/apps/server/src/migrations/0233__migrate_geo_map_to_collection.tsnew file mode 100644index 0000000000..b0f49144cd--- /dev/null+++ b/apps/server/src/migrations/0233__migrate_geo_map_to_collection.ts@@ -0,0 +1,47 @@+import type { AttachmentRow } from "@triliumnext/commons";+import becca from "../becca/becca";+import becca_loader from "../becca/becca_loader";+import cls from "../services/cls.js";+import hidden_subtree from "../services/hidden_subtree";++export default () => {+ cls.init(() => {+ becca_loader.load();++ // Ensure the geomap template is generated.+ hidden_subtree.checkHiddenSubtree(true);++ for (const note of Object.values(becca.notes)) {+ if (note.type !== "geoMap") {+ continue;+ }++ console.log(`Migrating note '${note.noteId}' from geoMap to book type...`);++ note.type = "book";+ note.mime = "";+ note.save();++ const content = note.getContent();+ if (content) {+ const title = "geoMap.json";+ const existingAttachment = note.getAttachmentsByRole("viewConfig")+ .filter(a => a.title === title)[0];+ if (existingAttachment) {+ existingAttachment.setContent(content);+ } else {+ note.saveAttachment({+ role: "viewConfig",+ title,+ mime: "application/json",+ content,+ position: 0+ });+ }++ }+ note.setContent("");+ note.setRelation("template", "_template_geo_map");+ }+ });+};diff --git a/apps/server/src/migrations/migrations.ts b/apps/server/src/migrations/migrations.tsindex 4743d92867..2757b4c25a 100644--- a/apps/server/src/migrations/migrations.ts+++ b/apps/server/src/migrations/migrations.ts@@ -6,6 +6,11 @@// Migrations should be kept in descending order, so the latest migration is first.const MIGRATIONS: (SqlMigration | JsMigration)[] = [+ // Migrate geo map to collection+ {+ version: 233,+ module: async () => import("./0233__migrate_geo_map_to_collection.js")+ },// Remove embedding tables since LLM embedding functionality has been removed{version: 232,diff --git a/apps/server/src/services/app_info.ts b/apps/server/src/services/app_info.tsindex b3da2ac0ea..0def562536 100644--- a/apps/server/src/services/app_info.ts+++ b/apps/server/src/services/app_info.ts@@ -3,7 +3,7 @@ import build from "./build.js";import packageJson from "../../package.json" with { type: "json" };import dataDir from "./data_dir.js";-const APP_DB_VERSION = 232;+const APP_DB_VERSION = 233;const SYNC_VERSION = 36;const CLIPPER_PROTOCOL_VERSION = "1.0";