fix: Remove NOW() from partial indexes (not immutable)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kelly
2025-12-14 15:58:05 -07:00
parent bbbd21ba94
commit 294d3db7a2
2 changed files with 4 additions and 4 deletions

View File

@@ -38,8 +38,8 @@ CREATE INDEX idx_inv_snap_brand_time ON inventory_snapshots(brand_name, captured
-- Platform filtering -- Platform filtering
CREATE INDEX idx_inv_snap_platform ON inventory_snapshots(platform, captured_at DESC); CREATE INDEX idx_inv_snap_platform ON inventory_snapshots(platform, captured_at DESC);
-- Retention cleanup (30 days) -- Retention cleanup (30 days) - simple index, cleanup job handles the WHERE
CREATE INDEX idx_inv_snap_cleanup ON inventory_snapshots(captured_at) WHERE captured_at < NOW() - INTERVAL '30 days'; CREATE INDEX IF NOT EXISTS idx_inv_snap_cleanup ON inventory_snapshots(captured_at);
-- Comments -- Comments
COMMENT ON TABLE inventory_snapshots IS 'Lightweight inventory snapshots for sales velocity tracking. Retained 30 days.'; COMMENT ON TABLE inventory_snapshots IS 'Lightweight inventory snapshots for sales velocity tracking. Retained 30 days.';

View File

@@ -44,8 +44,8 @@ CREATE INDEX idx_vis_events_type ON product_visibility_events(event_type, detect
-- Brand-level queries -- Brand-level queries
CREATE INDEX idx_vis_events_brand ON product_visibility_events(brand_name, event_type, detected_at DESC) WHERE brand_name IS NOT NULL; CREATE INDEX idx_vis_events_brand ON product_visibility_events(brand_name, event_type, detected_at DESC) WHERE brand_name IS NOT NULL;
-- Cleanup (90 days retention) -- Cleanup (90 days retention) - simple index, cleanup job handles the WHERE
CREATE INDEX idx_vis_events_cleanup ON product_visibility_events(detected_at) WHERE detected_at < NOW() - INTERVAL '90 days'; CREATE INDEX IF NOT EXISTS idx_vis_events_cleanup ON product_visibility_events(detected_at);
-- Comments -- Comments
COMMENT ON TABLE product_visibility_events IS 'Notable inventory events for alerting. OOS, brand drops, significant price changes. Retained 90 days.'; COMMENT ON TABLE product_visibility_events IS 'Notable inventory events for alerting. OOS, brand drops, significant price changes. Retained 90 days.';