diff --git a/ReactNativeClient/lib/joplin-database.js b/ReactNativeClient/lib/joplin-database.js index 62f5a1a7e..87cbc1b8b 100644 --- a/ReactNativeClient/lib/joplin-database.js +++ b/ReactNativeClient/lib/joplin-database.js @@ -326,7 +326,7 @@ class JoplinDatabase extends Database { // must be set in the synchronizer too. // Note: v16 and v17 don't do anything. They were used to debug an issue. - const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]; + const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]; let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion); @@ -735,6 +735,28 @@ class JoplinDatabase extends Database { ); } + if (targetVersion == 31) { + // This empty version is due to the revert of the hierarchical tag feature + // We need to keep the version for the users who have upgraded using + // the pre-release + queries.push('ALTER TABLE tags ADD COLUMN parent_id TEXT NOT NULL DEFAULT ""'); + // Drop the tag note count view, instead compute note count on the fly + // queries.push('DROP VIEW tags_with_note_count'); + // queries.push(this.addMigrationFile(31)); + } + + if (targetVersion == 32) { + // This is the same as version 25 - this is to complete the + // revert of the hierarchical tag feature. + queries.push(`CREATE VIEW IF NOT EXISTS tags_with_note_count AS + SELECT tags.id as id, tags.title as title, tags.created_time as created_time, tags.updated_time as updated_time, COUNT(notes.id) as note_count + FROM tags + LEFT JOIN note_tags nt on nt.tag_id = tags.id + LEFT JOIN notes on notes.id = nt.note_id + WHERE notes.id IS NOT NULL + GROUP BY tags.id`); + } + queries.push({ sql: 'UPDATE version SET version = ?', params: [targetVersion] }); try {