Subject: [bug#32121] [PATCH 3/5] database: Add support for database upgrades.

From: Clément Lassieur <[email-masked]>
Date: Sat, 14 Jul 2018 17:32:15 +0200

Clément Lassieur <[email-masked]> writes:

> +(define (db-get-version db)
> +  (if (pair? (sqlite-exec db "SELECT name FROM sqlite_master WHERE \
> +type='table' AND name='SchemaVersion';"))
> +      (vector-ref
> +       (car (sqlite-exec db "SELECT MAX(version) FROM SchemaVersion;")) 0)
> +      0))
> +
> +(define (db-set-version db version)
> +  (sqlite-exec db "INSERT INTO SchemaVersion (version) VALUES (" version
> +               ");"))

Actually, there is:

--8<---------------cut here---------------start------------->8---
PRAGMA schema.user_version;
PRAGMA schema.user_version = integer ;

The user_version pragma will to get or set the value of the user-version
integer at offset 60 in the database header. The user-version is an
integer that is available to applications to use however they
want. SQLite makes no use of the user-version itself.
--8<---------------cut here---------------end--------------->8---

Better use them than creating an ad-hoc table I guess, WDYT?