From 601ce32ee8d0cee32b66c87b0bfefa7424a5b8c8 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 18 Oct 2025 02:32:59 -0300 Subject: modify how automatic SQLite patches/upgrades works + overall cleanup --- sqlite/README.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'sqlite/README.txt') diff --git a/sqlite/README.txt b/sqlite/README.txt index 26f782a..8ef89f5 100644 --- a/sqlite/README.txt +++ b/sqlite/README.txt @@ -1,10 +1,11 @@ - The query manager will properly initialize and upgrade the database schema -based on files in this folder. The initial schema should be in `schema.sql` and -upgrades should be in `upgrade-N.sql` where N is a number starting from 1. The -`upgrade-N.sql` file should take the database from version N to N + 1. - The only restriction to these files is that they can't have transaction -statements ("BEGIN", "ROLLBACK", "COMMIT") because the query manager will -already bundle them into a transaction that also sets `user_version`, and -and nested transactions aren't allowed. - The current database version can be retrieved with the "PRAGMA user_version" -query in the SQLite shell. \ No newline at end of file + The query manager will initialize and patch the database schema, at startup, +based on the files in this folder. The initial schema is inside `schema.sql` and +shouldn't be modified, to make sure the database can be initialized if everything +else fails. Patches and modifications should be placed in `patches/` with no +particular name restrictions except for having an `.sql` extension. These patch +files will be executed exactly ONCE. If multiple patches are pending at startup, +they're executed in alphabetical order. + As for statement restrictions, the only thing prohibited is the presence of +transaction statements "BEGIN", "ROLLBACK", and "COMMIT". This is because all +patches will be bundled into the same transaction, to ensure atomicity. + -- cgit v1.2.3