Added schema.sql and testdata.sql, moved sql out of tests package

This commit is contained in:
2025-02-13 20:30:53 +11:00
parent 5b1532b86d
commit 62111df6c5
4 changed files with 68 additions and 14 deletions

18
schema.sql Normal file
View File

@@ -0,0 +1,18 @@
PRAGMA foreign_keys=ON;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS jwtblacklist (
jti TEXT PRIMARY KEY CHECK(jti GLOB '[0-9a-fA-F-]*'),
exp INTEGER NOT NULL
) STRICT;
CREATE TABLE IF NOT EXISTS "users" (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL UNIQUE,
password_hash TEXT,
created_at INTEGER DEFAULT (unixepoch())
) STRICT;
CREATE TRIGGER cleanup_expired_tokens
AFTER INSERT ON jwtblacklist
BEGIN
DELETE FROM jwtblacklist WHERE exp < strftime('%s', 'now');
END;
COMMIT;