-- Migration 114: Add pool_id to task_schedules
-- Allows schedules to target specific geo pools

ALTER TABLE task_schedules
ADD COLUMN IF NOT EXISTS pool_id INTEGER REFERENCES task_pools(id);

-- Index for pool-based schedule queries
CREATE INDEX IF NOT EXISTS idx_task_schedules_pool ON task_schedules(pool_id) WHERE pool_id IS NOT NULL;

COMMENT ON COLUMN task_schedules.pool_id IS 'Optional geo pool filter. NULL = all pools/dispensaries matching state_code';
