1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

All: Save size of a resource to the database; and added mechanism to run non-database migrations

This commit is contained in:
Laurent Cozic
2019-05-11 17:55:40 +01:00
parent e96bc9c48a
commit 9c85bc2cd1
11 changed files with 128 additions and 3 deletions

View File

@@ -263,7 +263,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];
const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion);
@@ -544,6 +544,22 @@ class JoplinDatabase extends Database {
queries.push('ALTER TABLE item_changes ADD COLUMN before_change_item TEXT NOT NULL DEFAULT ""');
}
if (targetVersion == 20) {
const newTableSql = `
CREATE TABLE migrations (
id INTEGER PRIMARY KEY,
number INTEGER NOT NULL,
updated_time INT NOT NULL,
created_time INT NOT NULL
);
`;
queries.push(this.sqlStringToLines(newTableSql)[0]);
const timestamp = Date.now();
queries.push('ALTER TABLE resources ADD COLUMN `size` INT NOT NULL DEFAULT -1');
queries.push({ sql: 'INSERT INTO migrations (number, created_time, updated_time) VALUES (20, ?, ?)', params: [timestamp, timestamp] });
}
queries.push({ sql: 'UPDATE version SET version = ?', params: [targetVersion] });
try {