server: auth schema, keys, sessions, connection registry (#17)

This commit is contained in:
2026-11-14 22:13:04 +01:00
parent c89c8eab42
commit e612db5826
11 changed files with 915 additions and 13 deletions
+10 -5
View File
@@ -38,19 +38,24 @@ suite "migrate":
check migrate(db) == LatestVersion
check LatestVersion == migrations[^1].version
check schemaVersion(db) == LatestVersion
check LatestVersion == 1
check LatestVersion == 2
let rows = appliedMigrations(db)
check rows.len == 1
check rows.len == 2
check rows[0][0] == 1
check rows[0][1] == "meta"
# the step's own DDL ran: meta exists and is empty
check rows[1][0] == 2
check rows[1][1] == "auth"
# the steps' own DDL ran: meta and the auth tables exist and are empty
check db.getValue(sql"SELECT count(*) FROM meta") == "0"
check db.getValue(sql"SELECT count(*) FROM player") == "0"
check db.getValue(sql"SELECT count(*) FROM player_key") == "0"
check db.getValue(sql"SELECT count(*) FROM session") == "0"
test "re-open is a no-op: no step applied, history and timestamps untouched":
let d = tmpDir()
block:
let db = openFresh(d)
check migrate(db) == 1
check migrate(db) == 2
close(db)
let db = openFresh(d)
defer:
@@ -59,7 +64,7 @@ suite "migrate":
let before = appliedMigrations(db)
check migrate(db) == 0
check migrate(db) == 0
check schemaVersion(db) == 1
check schemaVersion(db) == 2
check appliedMigrations(db) == before
test "history and user_version must agree":