feat: add single-profile settings table and store layer
Add Profile table to store Garmin credentials and engine configuration parameters. Implements GetProfile() and UpdateProfile() store methods with comprehensive test coverage. The profile singleton row is automatically initialized on migration and persists all configuration state. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
37
backend/internal/store/migrations/0003_profile.sql
Normal file
37
backend/internal/store/migrations/0003_profile.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
-- 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 50,
|
||||
hr_zone1_max_pct REAL NOT NULL DEFAULT 60,
|
||||
hr_zone2_min_pct REAL NOT NULL DEFAULT 60,
|
||||
hr_zone2_max_pct REAL NOT NULL DEFAULT 70,
|
||||
hr_zone3_min_pct REAL NOT NULL DEFAULT 70,
|
||||
hr_zone3_max_pct REAL NOT NULL DEFAULT 80,
|
||||
hr_zone4_min_pct REAL NOT NULL DEFAULT 80,
|
||||
hr_zone4_max_pct REAL NOT NULL DEFAULT 90,
|
||||
hr_zone5_min_pct REAL NOT NULL DEFAULT 90,
|
||||
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);
|
||||
Reference in New Issue
Block a user