fix sync of audit log

This commit is contained in:
azivner 2017-10-26 21:53:26 -04:00
parent 791314ba1a
commit 297da47b34
4 changed files with 21 additions and 3 deletions

View file

@ -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;

View file

@ -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);
}
}
});

View file

@ -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() {

View file

@ -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);