You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-02 22:49:09 +02:00
All: Fix database upgrade
This commit is contained in:
@@ -202,7 +202,7 @@ class JoplinDatabase extends Database {
|
||||
// default value and thus might cause problems. In that case, the default value
|
||||
// must be set in the synchronizer too.
|
||||
|
||||
const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
||||
|
||||
let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion);
|
||||
|
||||
@@ -298,7 +298,7 @@ class JoplinDatabase extends Database {
|
||||
queries.push('ALTER TABLE resources ADD COLUMN encryption_blob_encrypted INT NOT NULL DEFAULT 0');
|
||||
}
|
||||
|
||||
if (targetVersion == 10) {
|
||||
const upgradeVersion10 = () => {
|
||||
const itemChangesTable = `
|
||||
CREATE TABLE item_changes (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -331,6 +331,16 @@ class JoplinDatabase extends Database {
|
||||
queries.push({ sql: 'INSERT INTO item_changes (item_type, item_id, type, created_time) SELECT 1, id, 1, ? FROM notes', params: [Date.now()] });
|
||||
}
|
||||
|
||||
if (targetVersion == 10) {
|
||||
upgradeVersion10();
|
||||
}
|
||||
|
||||
if (targetVersion == 11) {
|
||||
queries.push('DROP TABLE item_changes');
|
||||
queries.push('DROP TABLE note_resources');
|
||||
upgradeVersion10();
|
||||
}
|
||||
|
||||
queries.push({ sql: 'UPDATE version SET version = ?', params: [targetVersion] });
|
||||
await this.transactionExecBatch(queries);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user