LifeMate — Personal, Family & Learning Companion

feat/aparat-learning-library
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 45 lines 3.28 KB
Raw
1 \set ON_ERROR_STOP on
2 begin;
3
4 insert into app_user(id,identity_subject,email_normalized) values
5 ('30000000-0000-0000-0000-000000000001','p3-parent','p3-parent@example.test'),
6 ('30000000-0000-0000-0000-000000000002','p3-teen','p3-teen@example.test'),
7 ('30000000-0000-0000-0000-000000000003','p3-other','p3-other@example.test');
8
9 insert into family_workspace(id,name,created_by) values
10 ('31000000-0000-0000-0000-000000000001','P3 Family','30000000-0000-0000-0000-000000000001');
11
12 insert into family_membership(family_id,user_id,role,is_admin) values
13 ('31000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000001','parent_guardian',true),
14 ('31000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000002','teen_minor',false);
15
16 insert into guardian_relationship(family_id,guardian_user_id,minor_user_id) values
17 ('31000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000002');
18
19 insert into plan_item(id,owner_user_id,family_id,kind,title,visibility,due_at) values
20 ('32000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000002','31000000-0000-0000-0000-000000000001','task','Private teen','private',now()+interval '1 day'),
21 ('32000000-0000-0000-0000-000000000002','30000000-0000-0000-0000-000000000002','31000000-0000-0000-0000-000000000001','assignment','Guardian item','parent_guardian',now()+interval '1 day'),
22 ('32000000-0000-0000-0000-000000000003','30000000-0000-0000-0000-000000000001','31000000-0000-0000-0000-000000000001','event','Family event','family',now()+interval '1 day');
23
24 do $$
25 begin
26 if not can_view_plan_item('30000000-0000-0000-0000-000000000002','32000000-0000-0000-0000-000000000001') then raise exception 'owner must see private item'; end if;
27 if can_view_plan_item('30000000-0000-0000-0000-000000000001','32000000-0000-0000-0000-000000000001') then raise exception 'guardian must not see private item'; end if;
28 if not can_view_plan_item('30000000-0000-0000-0000-000000000001','32000000-0000-0000-0000-000000000002') then raise exception 'guardian must see guardian item'; end if;
29 if can_view_plan_item('30000000-0000-0000-0000-000000000003','32000000-0000-0000-0000-000000000002') then raise exception 'outsider must not see guardian item'; end if;
30 if not can_view_plan_item('30000000-0000-0000-0000-000000000002','32000000-0000-0000-0000-000000000003') then raise exception 'family member must see family event'; end if;
31 if not can_view_student_academic('30000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000002') then raise exception 'guardian academic access missing'; end if;
32 if can_view_student_academic('30000000-0000-0000-0000-000000000003','30000000-0000-0000-0000-000000000002') then raise exception 'outsider academic access must fail'; end if;
33 end $$;
34
35 update family_membership set ended_at=now()
36 where family_id='31000000-0000-0000-0000-000000000001'
37 and user_id='30000000-0000-0000-0000-000000000001';
38
39 do $$
40 begin
41 if can_view_plan_item('30000000-0000-0000-0000-000000000001','32000000-0000-0000-0000-000000000002') then raise exception 'removed guardian must lose plan access'; end if;
42 if can_view_student_academic('30000000-0000-0000-0000-000000000001','30000000-0000-0000-0000-000000000002') then raise exception 'removed guardian must lose academic access'; end if;
43 end $$;
44
45 rollback;