-- Migration: 103_schedule_dispensary_id.sql
-- Description: Add dispensary_id to task_schedules for per-store schedules
-- Created: 2025-12-13

-- Add dispensary_id column for single-store schedules
ALTER TABLE task_schedules
ADD COLUMN IF NOT EXISTS dispensary_id INTEGER REFERENCES dispensaries(id);

-- Index for quick lookups
CREATE INDEX IF NOT EXISTS idx_task_schedules_dispensary_id ON task_schedules(dispensary_id);

COMMENT ON COLUMN task_schedules.dispensary_id IS 'For single-store schedules. If set, only this store is refreshed. If NULL, uses state_code for all stores in state.';
