diff --git a/migrations/0014__change_audit_log_id.sql b/migrations/0014__change_audit_log_id.sql new file mode 100644 index 000000000..c553ecfd0 --- /dev/null +++ b/migrations/0014__change_audit_log_id.sql @@ -0,0 +1,16 @@ +CREATE TABLE `audit_log_mig` ( + `id` TEXT NOT NULL PRIMARY KEY, + `date_modified` INTEGER NOT NULL, + `category` TEXT NOT NULL, + `browser_id` TEXT, + `note_id` TEXT, + `change_from` TEXT, + `change_to` TEXT, + `comment` TEXT +); + +INSERT INTO audit_log_mig (id, date_modified, category, browser_id, note_id, change_from, change_to) + SELECT id, date_modified, category, browser_id, note_id, change_from, change_to FROM audit_log; + +DROP TABLE audit_log; +ALTER TABLE audit_log_mig RENAME TO audit_log; \ No newline at end of file diff --git a/public/javascripts/tree.js b/public/javascripts/tree.js index 40c629a98..a5d1e6906 100644 --- a/public/javascripts/tree.js +++ b/public/javascripts/tree.js @@ -102,6 +102,10 @@ setInterval(() => { // if the user got logged out then we should display the page // here we do that by reloading which will force the redirect if the user is really logged out window.location.reload(true); + }, + 409: () => { + // 409 means we need to migrate database, reload will take care of it + window.location.reload(true); } } }); diff --git a/services/migration.js b/services/migration.js index 7b3564a50..01126d09e 100644 --- a/services/migration.js +++ b/services/migration.js @@ -3,7 +3,7 @@ const sql = require('./sql'); const fs = require('fs-extra'); const log = require('./log'); -const APP_DB_VERSION = 13; +const APP_DB_VERSION = 14; const MIGRATIONS_DIR = "./migrations"; async function migrate() { diff --git a/services/sync.js b/services/sync.js index 6059a218b..217c384ae 100644 --- a/services/sync.js +++ b/services/sync.js @@ -135,8 +135,6 @@ async function putChanged(changed) { } for (const audit of changed.audit_log) { - delete audit['id']; - await sql.insert("audit_log", audit, true); log.info("Update/sync audit_log for noteId=" + audit.note_id);