Add adaptive medication timing, Discord presence tracking, and nagging system
This commit is contained in:
@@ -200,3 +200,53 @@ CREATE TABLE IF NOT EXISTS med_logs (
|
||||
notes TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- ── Adaptive Medication Settings ─────────────────────────────
|
||||
|
||||
CREATE TABLE IF NOT EXISTS adaptive_med_settings (
|
||||
id UUID PRIMARY KEY,
|
||||
user_uuid UUID REFERENCES users(id) ON DELETE CASCADE UNIQUE,
|
||||
adaptive_timing_enabled BOOLEAN DEFAULT FALSE,
|
||||
adaptive_mode VARCHAR(20) DEFAULT 'shift_all',
|
||||
presence_tracking_enabled BOOLEAN DEFAULT FALSE,
|
||||
nagging_enabled BOOLEAN DEFAULT TRUE,
|
||||
nag_interval_minutes INTEGER DEFAULT 15,
|
||||
max_nag_count INTEGER DEFAULT 4,
|
||||
quiet_hours_start TIME,
|
||||
quiet_hours_end TIME,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- ── User Discord Presence Tracking ────────────────────────────
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_presence (
|
||||
id UUID PRIMARY KEY,
|
||||
user_uuid UUID REFERENCES users(id) ON DELETE CASCADE UNIQUE,
|
||||
discord_user_id VARCHAR(255),
|
||||
last_online_at TIMESTAMP,
|
||||
last_offline_at TIMESTAMP,
|
||||
is_currently_online BOOLEAN DEFAULT FALSE,
|
||||
typical_wake_time TIME,
|
||||
presence_history JSONB DEFAULT '[]',
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- ── Adaptive Medication Schedules (Daily Tracking) ───────────
|
||||
|
||||
CREATE TABLE IF NOT EXISTS medication_schedules (
|
||||
id UUID PRIMARY KEY,
|
||||
medication_id UUID REFERENCES medications(id) ON DELETE CASCADE,
|
||||
user_uuid UUID REFERENCES users(id) ON DELETE CASCADE,
|
||||
base_time TIME NOT NULL,
|
||||
adjusted_time TIME,
|
||||
adjustment_date DATE NOT NULL,
|
||||
adjustment_minutes INTEGER DEFAULT 0,
|
||||
nag_count INTEGER DEFAULT 0,
|
||||
last_nag_at TIMESTAMP,
|
||||
status VARCHAR(20) DEFAULT 'pending',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_med_schedules_user_date ON medication_schedules(user_uuid, adjustment_date);
|
||||
CREATE INDEX IF NOT EXISTS idx_med_schedules_status ON medication_schedules(status);
|
||||
|
||||
Reference in New Issue
Block a user