LifeMate — Personal, Family & Learning Companion

test/role-entry-apk
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
sql 53 lines 3.47 KB
Raw
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 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')),
8 created_at timestamptz not null default now(), updated_at timestamptz not null default now()
9 );
10 create table if not exists learning_checkin (
11 id uuid primary key default gen_random_uuid(), owner_user_id uuid not null references app_user(id) on delete cascade,
12 learning_goal_id uuid references learning_goal(id) on delete set null,
13 confidence smallint check(confidence between 1 and 5), difficulty smallint check(difficulty between 1 and 5), note text,
14 created_at timestamptz not null default now()
15 );
16 create table if not exists wellbeing_checkin (
17 id uuid primary key default gen_random_uuid(), owner_user_id uuid not null references app_user(id) on delete cascade,
18 mood smallint not null check(mood between 1 and 5), energy smallint check(energy between 1 and 5), stress smallint check(stress between 1 and 5), note text,
19 visibility text not null default 'private' check(visibility in ('private','guardian_summary')),
20 created_at timestamptz not null default now()
21 );
22 create table if not exists ai_guide_session (
23 id uuid primary key default gen_random_uuid(), owner_user_id uuid not null references app_user(id) on delete cascade,
24 guide_kind text not null check(guide_kind in ('study','planner','wellbeing')),
25 status text not null default 'active' check(status in ('active','closed')),
26 created_at timestamptz not null default now(), updated_at timestamptz not null default now()
27 );
28 create table if not exists ai_guide_message (
29 id uuid primary key default gen_random_uuid(), session_id uuid not null references ai_guide_session(id) on delete cascade,
30 author text not null check(author in ('user','assistant','system')), body text not null,
31 safety_class text not null default 'ordinary' check(safety_class in ('ordinary','supportive','urgent_review')),
32 created_at timestamptz not null default now()
33 );
34 create table if not exists ai_plan_proposal (
35 id uuid primary key default gen_random_uuid(), owner_user_id uuid not null references app_user(id) on delete cascade,
36 session_id uuid references ai_guide_session(id) on delete set null, title text not null, proposal jsonb not null,
37 status text not null default 'proposed' check(status in ('proposed','accepted','rejected')),
38 created_at timestamptz not null default now(), decided_at timestamptz
39 );
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);