fix: use epoch ms for PostgreSQL bigint columns in quota_state#171
Merged
fix: use epoch ms for PostgreSQL bigint columns in quota_state#171
Conversation
The quota_state table uses bigint columns for last_updated and window_start in PostgreSQL, but quota-enforcer.ts was passing Date objects instead of epoch millisecond numbers. This caused PostgresError: "column is of type bigint but expression is of type timestamp with time zone". Fix by: - Using toDbTimestampMs() for writes, which returns number for PostgreSQL and Date for SQLite (matching each schema's expected type) - Using fromDbTimestamp() helper for reads, which handles PostgreSQL returning epoch ms numbers vs SQLite returning Date objects - Removed all unsafe `as Date` casts on database-returned values Fixes #166 Co-authored-by: Matt Cowger <mcowger@users.noreply.github.com>
github-actions bot
pushed a commit
that referenced
this pull request
Apr 16, 2026
fix: use epoch ms for PostgreSQL bigint columns in quota_state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #166
The quota_state table uses bigint columns for last_updated and window_start in PostgreSQL, but quota-enforcer.ts was passing Date objects instead of epoch millisecond numbers. This caused PostgresError: "column is of type bigint but expression is of type timestamp with time zone".
Fix by using toDbTimestampMs() for writes and fromDbTimestamp() for reads to properly handle the type difference between PostgreSQL (number) and SQLite (Date).
Generated with Claude Code