From 294d3db7a288b24d78a025048e9b4fd63431cfe7 Mon Sep 17 00:00:00 2001 From: Kelly Date: Sun, 14 Dec 2025 15:58:05 -0700 Subject: [PATCH] fix: Remove NOW() from partial indexes (not immutable) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- backend/migrations/118_inventory_snapshots.sql | 4 ++-- backend/migrations/119_product_visibility_events.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/migrations/118_inventory_snapshots.sql b/backend/migrations/118_inventory_snapshots.sql index 78a67a88..636a53d0 100644 --- a/backend/migrations/118_inventory_snapshots.sql +++ b/backend/migrations/118_inventory_snapshots.sql @@ -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.'; diff --git a/backend/migrations/119_product_visibility_events.sql b/backend/migrations/119_product_visibility_events.sql index 1d8d8fd3..5a5aa417 100644 --- a/backend/migrations/119_product_visibility_events.sql +++ b/backend/migrations/119_product_visibility_events.sql @@ -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.';