mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
feat(views/geomap): migrate db to new collection type
This commit is contained in:
parent
ce33dfb003
commit
f5a6dfa629
@ -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");
|
||||
}
|
||||
});
|
||||
};
|
@ -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,
|
||||
|
@ -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";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user