feat(views/geomap): migrate db to new collection type

This commit is contained in:
Elian Doran 2025-07-06 20:17:15 +03:00
parent ce33dfb003
commit f5a6dfa629
No known key found for this signature in database
3 changed files with 53 additions and 1 deletions

View File

@ -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");
}
});
};

View File

@ -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,

View File

@ -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";