iens

Manager of links to read
git clone https://git.instinctive.eu/iens.git
Log | Files | Refs | README | LICENSE

commit 4c8773fb1658c9790c5d34af1d0d1ebd632fca34
parent c8e94574038d3098fe6f0df649e6902612b2eafb
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Wed,  6 Mar 2024 22:04:13 +0000

Feeds have a recorded modification time
Diffstat:
Msrc/iens.scm | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/iens.scm b/src/iens.scm @@ -115,7 +115,7 @@ ;; Database Creation/Migration (when (null? (schema db)) - (write-line (conc "Initializing database with schema v1")) + (write-line "Initializing database with schema v2") (for-each (lambda (s) (exec (sql/transient db s))) (list "CREATE TABLE config (key TEXT PRIMARY KEY, val);" @@ -134,7 +134,8 @@ "CREATE TABLE feed (id INTEGER PRIMARY KEY, filename TEXT NOT NULL, url TEXT NOT NULL, selector TEXT NOT NULL, title TEXT NOT NULL, - active INTEGER NOT NULL DEFAULT 1);" + active INTEGER NOT NULL DEFAULT 1, + mtime INTEGER);" "CREATE TABLE selector (id INTEGER PRIMARY KEY, text TEXT);" "CREATE INDEX i_mtime ON entry(mtime);" "CREATE INDEX i_pmtime ON entry(protected,mtime);" @@ -143,9 +144,10 @@ "CREATE UNIQUE INDEX i_rel0 ON tagrel(url_id,tag_id);" "CREATE INDEX i_rel1 ON tagrel(url_id);" "CREATE INDEX i_rel2 ON tagrel(tag_id);" - "PRAGMA user_version = 1;"))) + "PRAGMA user_version = 2;"))) (when (= 0 (db-version)) + (write-line "Updating database schema from v0 to v1") (assert (= 1 (query fetch-value (sql db "SELECT val FROM config WHERE key = ?;") "schema-version"))) @@ -156,7 +158,14 @@ "DELETE FROM config WHERE key='schema-version';" "PRAGMA user_version = 1;"))) -(assert (= 1 (db-version))) +(when (= 1 (db-version)) + (write-line "Updating database schema from v1 to v2") + (for-each + (lambda (s) (exec (sql/transient db s))) + (list "ALTER TABLE feed ADD COLUMN mtime INTEGER;" + "PRAGMA user_version = 2;"))) + +(assert (= 2 (db-version))) ;;;;;;;;;;;;;;;;;; ;; Configuration