LifeMate — Personal, Family & Learning Companion
fix: validate phase 4 schema and add safety event ledger
davoodmehraban89 committed
Oct 5, 2026 at 16:11 UTC
c3ca6b388297ad0e785f3100b133c76fb198629b
1 file changed
+12
-1
backend/migrations/0004_ai_learning_wellbeing.sql
+12
-1
@@ -1,7 +1,7 @@
1
create table if not exists learning_goal (
2
id uuid primary key default gen_random_uuid(),
3
owner_user_id uuid not null references app_user(id) on delete cascade,
4
- subject_id uuid references academic_subject(id) on delete set null,
4
+ subject_id uuid references subject(id) on delete set null,
5
title text not null,
6
target text,
7
status text not null default 'active' check (status in ('active','completed','archived')),
@@ -40,3 +40,14 @@ create table if not exists ai_plan_proposal (
40
create index if not exists learning_goal_owner_idx on learning_goal(owner_user_id,status);
41
create index if not exists wellbeing_checkin_owner_idx on wellbeing_checkin(owner_user_id,created_at desc);
42
create index if not exists ai_guide_session_owner_idx on ai_guide_session(owner_user_id,created_at desc);
43
+
44
+create table if not exists wellbeing_safety_event (
45
+ id uuid primary key default gen_random_uuid(),
46
+ owner_user_id uuid not null references app_user(id) on delete cascade,
47
+ source_session_id uuid references ai_guide_session(id) on delete set null,
48
+ severity text not null check(severity in ('urgent_review')),
49
+ status text not null default 'open' check(status in ('open','acknowledged','closed')),
50
+ created_at timestamptz not null default now(),
51
+ acknowledged_at timestamptz
52
+);
53
+create index if not exists wellbeing_safety_event_owner_idx on wellbeing_safety_event(owner_user_id,created_at desc);