Files
geniusrun/backend/internal/store/migrations/0003_profile.sql
Christophe Vila 57be9065cd feat: add profile REST endpoints with HR zone validation
Implements GET /api/profile and PUT /api/profile endpoints with validation
of HR zones (must be contiguous, non-overlapping, 0-100%). Also updates
profile migration to use correct HR zone defaults (0-20, 20-40, etc.)
that match validation requirements.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-17 19:03:29 +02:00

38 lines
1.8 KiB
SQL

-- Single-profile settings: Garmin credentials (replacing env-var-only
-- config) and every tunable engine parameter, in one editable row.
CREATE TABLE profile (
id INTEGER PRIMARY KEY CHECK (id = 1),
garmin_email TEXT NOT NULL DEFAULT '',
garmin_password TEXT NOT NULL DEFAULT '',
rolling_window_days INTEGER NOT NULL DEFAULT 90,
max_heart_rate REAL,
resting_heart_rate REAL,
hr_zone1_min_pct REAL NOT NULL DEFAULT 0,
hr_zone1_max_pct REAL NOT NULL DEFAULT 20,
hr_zone2_min_pct REAL NOT NULL DEFAULT 20,
hr_zone2_max_pct REAL NOT NULL DEFAULT 40,
hr_zone3_min_pct REAL NOT NULL DEFAULT 40,
hr_zone3_max_pct REAL NOT NULL DEFAULT 60,
hr_zone4_min_pct REAL NOT NULL DEFAULT 60,
hr_zone4_max_pct REAL NOT NULL DEFAULT 80,
hr_zone5_min_pct REAL NOT NULL DEFAULT 80,
hr_zone5_max_pct REAL NOT NULL DEFAULT 100,
easy_warmup_minutes REAL NOT NULL DEFAULT 10,
easy_cooldown_minutes REAL NOT NULL DEFAULT 5,
long_warmup_minutes REAL NOT NULL DEFAULT 10,
long_cooldown_minutes REAL NOT NULL DEFAULT 5,
tempo_warmup_minutes REAL NOT NULL DEFAULT 15,
tempo_cooldown_minutes REAL NOT NULL DEFAULT 10,
threshold30_warmup_minutes REAL NOT NULL DEFAULT 15,
threshold30_cooldown_minutes REAL NOT NULL DEFAULT 10,
threshold60_warmup_minutes REAL NOT NULL DEFAULT 15,
threshold60_cooldown_minutes REAL NOT NULL DEFAULT 10,
mas_test_warmup_minutes REAL NOT NULL DEFAULT 15,
mas_test_cooldown_minutes REAL NOT NULL DEFAULT 5,
interval_warmup_minutes REAL NOT NULL DEFAULT 0,
interval_cooldown_minutes REAL NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
INSERT INTO profile (id) VALUES (1);