2020-12-05 15:26:54 +05:00
|
|
|
export const migrations = {
|
|
|
|
|
0: {
|
2020-12-06 10:52:00 +05:00
|
|
|
note: function (item) {
|
2020-12-07 12:02:01 +05:00
|
|
|
// note.content -> note.contentId
|
2020-12-06 11:13:17 +05:00
|
|
|
if (item.content) {
|
|
|
|
|
const contentId = item.content.delta;
|
|
|
|
|
delete item.content;
|
|
|
|
|
item.contentId = contentId;
|
|
|
|
|
}
|
2020-12-07 12:02:01 +05:00
|
|
|
|
|
|
|
|
return migrations[2].note(item);
|
2020-12-05 15:26:54 +05:00
|
|
|
},
|
2020-12-06 10:52:00 +05:00
|
|
|
delta: function (item) {
|
2020-12-05 15:26:54 +05:00
|
|
|
item.data = item.data.ops;
|
|
|
|
|
item.type = "delta";
|
2020-12-06 15:35:23 +05:00
|
|
|
item.migrated = true;
|
2020-12-06 10:52:00 +05:00
|
|
|
return item;
|
2020-12-05 15:26:54 +05:00
|
|
|
},
|
2020-12-06 10:52:00 +05:00
|
|
|
trash: function (item) {
|
2020-12-05 15:26:54 +05:00
|
|
|
item.itemType = item.type;
|
|
|
|
|
item.type = "trash";
|
|
|
|
|
if (item.itemType === "note") {
|
|
|
|
|
item.contentId = item.content.delta;
|
|
|
|
|
delete item.content;
|
|
|
|
|
}
|
2020-12-06 15:35:23 +05:00
|
|
|
item.migrated = true;
|
2020-12-06 10:52:00 +05:00
|
|
|
return item;
|
2020-12-05 15:26:54 +05:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
2: {
|
2020-12-06 10:52:00 +05:00
|
|
|
note: function (item) {
|
2020-12-07 12:02:01 +05:00
|
|
|
// note.notebook -> note.notebooks
|
2020-12-05 15:26:54 +05:00
|
|
|
const notebook = item.notebook;
|
|
|
|
|
delete item.notebook;
|
2020-12-07 13:02:50 +05:00
|
|
|
if (notebook && notebook.id && notebook.topic) {
|
2020-12-08 11:58:45 +05:00
|
|
|
notebook.topics = [notebook.topic];
|
2020-12-07 12:02:01 +05:00
|
|
|
delete notebook.topic;
|
|
|
|
|
item.notebooks = [notebook];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return migrations[3].note(item);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
3: {
|
|
|
|
|
note: function (item) {
|
|
|
|
|
// note.colors -> note.color
|
|
|
|
|
if (item.colors && item.colors.length > 0) item.color = item.colors.pop();
|
|
|
|
|
delete item.colors;
|
|
|
|
|
|
2020-12-07 13:11:44 +05:00
|
|
|
return migrations[4].note(item);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
4: {
|
|
|
|
|
note: function (item) {
|
|
|
|
|
if (item.notebooks && item.notebooks.every((n) => !n.id)) {
|
|
|
|
|
item.notebooks = undefined;
|
|
|
|
|
}
|
2020-12-08 12:23:35 +05:00
|
|
|
return migrations["4.1"].note(item);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
4.1: {
|
|
|
|
|
note: function (item) {
|
|
|
|
|
return migrations["4.2"].note(item);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
4.2: {
|
|
|
|
|
note: function (item) {
|
|
|
|
|
if (item.notebooks) {
|
|
|
|
|
item.notebooks = item.notebooks.map((nb) => {
|
|
|
|
|
return { id: nb.id, topics: nb.topics || [nb.topic] };
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-12-06 15:35:23 +05:00
|
|
|
item.migrated = true;
|
2020-12-06 10:52:00 +05:00
|
|
|
return item;
|
2020-12-05 15:26:54 +05:00
|
|
|
},
|
|
|
|
|
},
|
2020-12-08 12:23:35 +05:00
|
|
|
4.3: {
|
2020-12-06 10:52:00 +05:00
|
|
|
note: false,
|
2020-12-07 13:11:44 +05:00
|
|
|
notebook: false,
|
2020-12-06 10:52:00 +05:00
|
|
|
tag: false,
|
|
|
|
|
trash: false,
|
2020-12-06 11:13:17 +05:00
|
|
|
delta: false,
|
2020-12-06 10:52:00 +05:00
|
|
|
settings: false,
|
2020-12-05 15:26:54 +05:00
|
|
|
},
|
|
|
|
|
};
|