fix: remove volatile NOW() from banner index predicate
PostgreSQL forbids volatile functions in partial index predicates. Replace with two plain indexes on starts_at and ends_at instead — the active-banner filtering is handled in the query WHERE clause. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,5 +10,5 @@ CREATE TABLE IF NOT EXISTS announcement_banners (
|
|||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX idx_banners_active ON announcement_banners (starts_at, ends_at)
|
CREATE INDEX idx_banners_starts_at ON announcement_banners (starts_at);
|
||||||
WHERE ends_at IS NULL OR ends_at > NOW();
|
CREATE INDEX idx_banners_ends_at ON announcement_banners (ends_at);
|
||||||
|
|||||||
Reference in New Issue
Block a user