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:
@@ -38,8 +38,8 @@ CREATE INDEX idx_inv_snap_brand_time ON inventory_snapshots(brand_name, captured
|
||||
-- Platform filtering
|
||||
CREATE INDEX idx_inv_snap_platform ON inventory_snapshots(platform, captured_at DESC);
|
||||
|
||||
-- Retention cleanup (30 days)
|
||||
CREATE INDEX idx_inv_snap_cleanup ON inventory_snapshots(captured_at) WHERE captured_at < NOW() - INTERVAL '30 days';
|
||||
-- Retention cleanup (30 days) - simple index, cleanup job handles the WHERE
|
||||
CREATE INDEX IF NOT EXISTS idx_inv_snap_cleanup ON inventory_snapshots(captured_at);
|
||||
|
||||
-- Comments
|
||||
COMMENT ON TABLE inventory_snapshots IS 'Lightweight inventory snapshots for sales velocity tracking. Retained 30 days.';
|
||||
|
||||
@@ -44,8 +44,8 @@ CREATE INDEX idx_vis_events_type ON product_visibility_events(event_type, detect
|
||||
-- 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;
|
||||
|
||||
-- Cleanup (90 days retention)
|
||||
CREATE INDEX idx_vis_events_cleanup ON product_visibility_events(detected_at) WHERE detected_at < NOW() - INTERVAL '90 days';
|
||||
-- Cleanup (90 days retention) - simple index, cleanup job handles the WHERE
|
||||
CREATE INDEX IF NOT EXISTS idx_vis_events_cleanup ON product_visibility_events(detected_at);
|
||||
|
||||
-- Comments
|
||||
COMMENT ON TABLE product_visibility_events IS 'Notable inventory events for alerting. OOS, brand drops, significant price changes. Retained 90 days.';
|
||||
|
||||
Reference in New Issue
Block a user