Workers check their timezone (from preflight IP geolocation) and current hour's weight probability to determine availability. This creates natural traffic patterns - more workers active during peak hours, fewer during off-peak. Tasks queue up at night and drain during the day. Migrations: - 099: working_hours table with hourly weights by profile - 100: Add timezone column to worker_registry - 101: Store timezone from preflight IP geolocation - 102: check_working_hours() function with probability roll 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
20 lines
964 B
SQL
20 lines
964 B
SQL
-- Migration: 100_worker_timezone.sql
|
|
-- Description: Add timezone column to worker_registry for working hours support
|
|
-- Created: 2024-12-13
|
|
|
|
-- Add timezone column to worker_registry
|
|
-- Populated from preflight IP geolocation (e.g., 'America/New_York')
|
|
ALTER TABLE worker_registry
|
|
ADD COLUMN IF NOT EXISTS timezone VARCHAR(50);
|
|
|
|
-- Add working_hours_id to link worker to a specific working hours profile
|
|
-- NULL means use default 'natural_traffic' profile
|
|
ALTER TABLE worker_registry
|
|
ADD COLUMN IF NOT EXISTS working_hours_id INTEGER REFERENCES working_hours(id);
|
|
|
|
-- Index for workers by timezone (useful for capacity planning)
|
|
CREATE INDEX IF NOT EXISTS idx_worker_registry_timezone ON worker_registry(timezone);
|
|
|
|
COMMENT ON COLUMN worker_registry.timezone IS 'IANA timezone from preflight IP geolocation (e.g., America/New_York)';
|
|
COMMENT ON COLUMN worker_registry.working_hours_id IS 'Reference to working_hours profile. NULL uses default natural_traffic.';
|