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>
15 lines
561 B
SQL
15 lines
561 B
SQL
CREATE TYPE banner_level AS ENUM ('info', 'important', 'critical');
|
|
|
|
CREATE TABLE IF NOT EXISTS announcement_banners (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
message TEXT NOT NULL,
|
|
level banner_level NOT NULL DEFAULT 'info',
|
|
starts_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
ends_at TIMESTAMPTZ,
|
|
created_by UUID REFERENCES users(id) ON DELETE SET NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_banners_starts_at ON announcement_banners (starts_at);
|
|
CREATE INDEX idx_banners_ends_at ON announcement_banners (ends_at);
|