From ca42a979c114e99d6c6222a475a84cdc24fade5c Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Sat, 22 Feb 2025 16:24:58 +1100 Subject: [PATCH] Fixed catastrophic bug caused by rows not being closed on db ver check --- db/connection.go | 1 + migrate/migrations/00001_init.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/db/connection.go b/db/connection.go index 7343ee5..a156590 100644 --- a/db/connection.go +++ b/db/connection.go @@ -41,6 +41,7 @@ func checkDBVersion(db *sql.DB, expectVer int) error { if err != nil { return errors.Wrap(err, "checkDBVersion") } + defer rows.Close() if rows.Next() { var version int err = rows.Scan(&version) diff --git a/migrate/migrations/00001_init.sql b/migrate/migrations/00001_init.sql index 1ada972..ccdf336 100644 --- a/migrate/migrations/00001_init.sql +++ b/migrate/migrations/00001_init.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS "users" ( created_at INTEGER DEFAULT (unixepoch()), bio TEXT DEFAULT "" ) STRICT; -CREATE TRIGGER cleanup_expired_tokens +CREATE TRIGGER IF NOT EXISTS cleanup_expired_tokens AFTER INSERT ON jwtblacklist BEGIN DELETE FROM jwtblacklist WHERE exp < strftime('%s', 'now');