Centralize the current-timestamp SQL expression

"strftime('%Y-%m-%dT%H:%M:%SZ', 'now')" was a private nowExpr()
method copy-pasted identically in CardRepository, CardStatusRepository
and ProjectRepository, and inlined as a raw literal directly in
PasskeyRepository, WebAuthnChallengeRepository, UserRepository and
EmailVerificationRepository -- 7 files, ~12 occurrences of the same
string. Now one Database::nowExpr() static method (Support/Database
already being the natural home for SQLite-specific concerns), used
everywhere a repository sets a timestamp explicitly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-04 21:41:25 +01:00
co-authored by Claude Sonnet 5
parent 029c05c46f
commit accc6a273c
8 changed files with 37 additions and 38 deletions
+10
View File
@@ -29,4 +29,14 @@ final class Database
{
return $this->pdo;
}
/**
* SQL expression for the current UTC time, in the format every
* created_at/updated_at/*_at column uses (both as their DEFAULT in the
* migrations and wherever a repository sets one explicitly).
*/
public static function nowExpr(): string
{
return "strftime('%Y-%m-%dT%H:%M:%SZ', 'now')";
}
}