From c5870f9e6ff75f94c36bc11b80d74224d09c4f96 Mon Sep 17 00:00:00 2001 From: Pantry Lead Agent Date: Wed, 25 Feb 2026 01:22:51 +0000 Subject: [PATCH] fix: correct table name to inventory_items in migration --- .../migrations/006_add_expiry_lowstock.sql | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/supabase/migrations/006_add_expiry_lowstock.sql b/supabase/migrations/006_add_expiry_lowstock.sql index 2f04b1b..d2bfa4f 100644 --- a/supabase/migrations/006_add_expiry_lowstock.sql +++ b/supabase/migrations/006_add_expiry_lowstock.sql @@ -2,21 +2,25 @@ -- Issues: #63 (expiry tracking), #67 (low-stock threshold) -- Created: 2026-02-25 --- Add expires_at column for expiry date tracking -ALTER TABLE pantry_items +-- Note: expiry_date already exists as DATE type. Adding expires_at as TIMESTAMPTZ for consistency +-- and low_stock_threshold for threshold tracking. + +-- Add expires_at column for precise expiry date/time tracking (complementing existing expiry_date) +-- We'll keep both: expiry_date (DATE) for simple day-based expiry, expires_at (TIMESTAMPTZ) for precise tracking +ALTER TABLE inventory_items ADD COLUMN expires_at TIMESTAMP WITH TIME ZONE DEFAULT NULL; -- Add low_stock_threshold column for low-stock alerts -ALTER TABLE pantry_items +ALTER TABLE inventory_items ADD COLUMN low_stock_threshold NUMERIC(10,2) DEFAULT NULL; -- Add comments for documentation -COMMENT ON COLUMN pantry_items.expires_at IS 'Optional expiration date for the item. Null means no expiry tracking.'; -COMMENT ON COLUMN pantry_items.low_stock_threshold IS 'Minimum quantity threshold. Item is considered low-stock when quantity <= threshold. Null means no threshold set.'; +COMMENT ON COLUMN inventory_items.expires_at IS 'Optional precise expiration timestamp. Complements expiry_date for items needing time-specific expiry.'; +COMMENT ON COLUMN inventory_items.low_stock_threshold IS 'Minimum quantity threshold. Item is considered low-stock when quantity <= threshold. Null means no threshold set.'; -- Create index for efficient expiry queries (finding items expiring soon) -CREATE INDEX idx_pantry_items_expires_at ON pantry_items(expires_at) WHERE expires_at IS NOT NULL; +CREATE INDEX idx_inventory_items_expires_at ON inventory_items(expires_at) WHERE expires_at IS NOT NULL; -- Create index for efficient low-stock queries -CREATE INDEX idx_pantry_items_low_stock ON pantry_items(quantity, low_stock_threshold) +CREATE INDEX idx_inventory_items_low_stock ON inventory_items(quantity, low_stock_threshold) WHERE low_stock_threshold IS NOT NULL;