mirror of
https://github.com/zadam/trilium.git
synced 2024-12-25 16:51:16 +08:00
note history snapshots now have date from and date to
This commit is contained in:
parent
11bbf9e633
commit
d1981eb6c3
6 changed files with 12 additions and 6 deletions
|
@ -0,0 +1,3 @@
|
|||
CREATE TABLE notes_history_mig AS SELECT id, note_id, note_title, note_text, date_modified AS date_modified_from, date_modified AS date_modified_to FROM notes_history;
|
||||
DROP TABLE notes_history;
|
||||
ALTER TABLE notes_history_mig RENAME TO notes_history;
|
1
migrations/0007__readd_encryption_to_note_history.sql
Normal file
1
migrations/0007__readd_encryption_to_note_history.sql
Normal file
|
@ -0,0 +1 @@
|
|||
ALTER TABLE notes_history ADD COLUMN encryption INTEGER DEFAULT 0
|
|
@ -21,7 +21,7 @@ function showNoteHistoryDialog(noteId, noteHistoryId) {
|
|||
globalHistoryItems = result;
|
||||
|
||||
for (const row of result) {
|
||||
const dateModified = getDateFromTS(row.date_modified);
|
||||
const dateModified = getDateFromTS(row.date_modified_to);
|
||||
|
||||
$("#note-history-list").append($('<option>', {
|
||||
value: row.id,
|
||||
|
|
|
@ -8,7 +8,7 @@ const auth = require('../../services/auth');
|
|||
router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
|
||||
const noteId = req.params.noteId;
|
||||
|
||||
const history = await sql.getResults("select * from notes_history where note_id = ? order by date_modified desc", [noteId]);
|
||||
const history = await sql.getResults("select * from notes_history where note_id = ? order by date_modified_to desc", [noteId]);
|
||||
|
||||
res.send(history);
|
||||
});
|
||||
|
|
|
@ -42,24 +42,26 @@ router.put('/:noteId', async (req, res, next) => {
|
|||
|
||||
const historyCutoff = now - historySnapshotTimeInterval;
|
||||
|
||||
const history = await sql.getSingleResult("select id from notes_history where note_id = ? and date_modified >= ?", [noteId, historyCutoff]);
|
||||
const history = await sql.getSingleResult("select id from notes_history where note_id = ? and date_modified_from >= ?", [noteId, historyCutoff]);
|
||||
|
||||
await sql.beginTransaction();
|
||||
|
||||
if (history) {
|
||||
await sql.execute("update notes_history set note_title = ?, note_text = ?, encryption = ? where id = ?", [
|
||||
await sql.execute("update notes_history set note_title = ?, note_text = ?, encryption = ?, date_modified_to = ? where id = ?", [
|
||||
note['detail']['note_title'],
|
||||
note['detail']['note_text'],
|
||||
note['detail']['encryption'],
|
||||
now,
|
||||
history['id']
|
||||
]);
|
||||
}
|
||||
else {
|
||||
await sql.execute("insert into notes_history (note_id, note_title, note_text, encryption, date_modified) values (?, ?, ?, ?, ?)", [
|
||||
await sql.execute("insert into notes_history (note_id, note_title, note_text, encryption, date_modified_from, date_modified_to) values (?, ?, ?, ?, ?, ?)", [
|
||||
noteId,
|
||||
note['detail']['note_title'],
|
||||
note['detail']['note_text'],
|
||||
note['detail']['encryption'],
|
||||
now,
|
||||
now
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ const backup = require('./backup');
|
|||
const sql = require('./sql');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
const APP_DB_VERSION = 5;
|
||||
const APP_DB_VERSION = 7;
|
||||
const MIGRATIONS_DIR = "./migrations";
|
||||
|
||||
async function migrate() {
|
||||
|
|
Loading…
Reference in a new issue