LifeMate — Personal, Family & Learning Companion
feat/standalone-weekly-planner
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
| 1 | begin; |
| 2 | |
| 3 | alter table plan_item add column if not exists version bigint not null default 0; |
| 4 | alter table plan_item alter column version set default 1; |
| 5 | alter table plan_item add column planned_duration_seconds integer |
| 6 | check(planned_duration_seconds is null or planned_duration_seconds between 0 and 86400); |
| 7 | update plan_item set planned_duration_seconds=duration_minutes*60 where duration_minutes is not null; |
| 8 | |
| 9 | alter table sync_mutation drop constraint sync_mutation_pkey; |
| 10 | alter table sync_mutation add primary key(user_id,id); |
| 11 | alter table sync_mutation drop constraint sync_mutation_operation_check; |
| 12 | alter table sync_mutation add constraint sync_mutation_operation_check |
| 13 | check(operation in ('create','update','complete','reschedule','archive')); |
| 14 | alter table sync_mutation add column request_hash text; |
| 15 | alter table sync_mutation add column canonical_item jsonb; |
| 16 | |
| 17 | create or replace function is_active_family_member(p_family uuid,p_user uuid) returns boolean |
| 18 | language sql stable as $$ |
| 19 | select exists(select 1 from family_membership m join family_workspace f on f.id=m.family_id |
| 20 | where m.family_id=p_family and m.user_id=p_user and m.ended_at is null and f.archived_at is null) |
| 21 | $$; |
| 22 | create or replace function is_active_guardian(p_family uuid,p_guardian uuid,p_minor uuid) returns boolean |
| 23 | language sql stable as $$ |
| 24 | select exists(select 1 from guardian_relationship g |
| 25 | join family_workspace f on f.id=g.family_id and f.archived_at is null |
| 26 | join family_membership gm on gm.family_id=g.family_id and gm.user_id=g.guardian_user_id |
| 27 | and gm.ended_at is null and gm.role='parent_guardian' |
| 28 | join family_membership mm on mm.family_id=g.family_id and mm.user_id=g.minor_user_id |
| 29 | and mm.ended_at is null and mm.role='teen_minor' |
| 30 | where g.family_id=p_family and g.guardian_user_id=p_guardian and g.minor_user_id=p_minor and g.active) |
| 31 | $$; |
| 32 | create or replace function is_family_admin(p_family uuid,p_user uuid) returns boolean |
| 33 | language sql stable as $$ |
| 34 | select exists(select 1 from family_membership m join family_workspace f on f.id=m.family_id |
| 35 | where m.family_id=p_family and m.user_id=p_user and m.ended_at is null and m.is_admin and f.archived_at is null) |
| 36 | $$; |
| 37 | |
| 38 | -- Legacy planner PATCH/sync writes still record explicit self-reported activity |
| 39 | -- transitions. Dedicated study/activity writes already advance activity_version. |
| 40 | create function plan_item_legacy_activity() returns trigger language plpgsql as $$ |
| 41 | begin |
| 42 | if new.status is distinct from old.status and new.activity_version=old.activity_version |
| 43 | and new.status<>'cancelled' then |
| 44 | new.activity_version := old.activity_version+1; |
| 45 | insert into activity_state_event(plan_item_id,actor_user_id,state,source,occurred_at,version) |
| 46 | values(new.id,new.owner_user_id, |
| 47 | case new.status when 'completed' then 'completed' when 'in_progress' then 'started' else 'planned' end, |
| 48 | 'self_reported',coalesce(new.completed_at,new.updated_at),new.activity_version); |
| 49 | end if; |
| 50 | return new; |
| 51 | end $$; |
| 52 | create trigger plan_item_legacy_activity before update on plan_item |
| 53 | for each row execute function plan_item_legacy_activity(); |
| 54 | |
| 55 | commit; |