LifeMate — Personal, Family & Learning Companion
fix/personal-notification-controls
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 | -- Synthetic-only child identity foundation. Runtime gate is mandatory and never |
| 4 | -- permits production. This migration does not approve legal consent or data hosting. |
| 5 | alter table app_user add column is_managed_child boolean not null default false; |
| 6 | alter table app_user drop constraint app_user_contact_required; |
| 7 | alter table app_user add constraint app_user_contact_required |
| 8 | check (email_normalized is not null or phone_normalized is not null or is_managed_child); |
| 9 | alter table app_user add constraint managed_child_has_no_contact |
| 10 | check (not is_managed_child or (email_normalized is null and phone_normalized is null)); |
| 11 | |
| 12 | alter table auth_session add column access_scope text not null default 'standard' |
| 13 | check (access_scope in ('standard','child_education')); |
| 14 | alter table auth_session add column child_issuer_user_id uuid references app_user(id); |
| 15 | |
| 16 | create table managed_child ( |
| 17 | user_id uuid primary key references app_user(id) on delete cascade, |
| 18 | family_id uuid not null references family_workspace(id) on delete cascade, |
| 19 | creator_user_id uuid not null references app_user(id), |
| 20 | created_at timestamptz not null default clock_timestamp(), |
| 21 | unique (family_id,user_id), |
| 22 | check (user_id<>creator_user_id) |
| 23 | ); |
| 24 | |
| 25 | create table child_consent ( |
| 26 | child_user_id uuid primary key references managed_child(user_id) on delete cascade, |
| 27 | actor_user_id uuid not null references app_user(id), |
| 28 | text_version text not null check (text_version='sandbox-child-consent-v1-not-legal'), |
| 29 | text_digest text not null check (text_digest ~ '^[a-f0-9]{64}$'), |
| 30 | accepted_at timestamptz not null default clock_timestamp(), |
| 31 | revoked_at timestamptz |
| 32 | ); |
| 33 | |
| 34 | create table child_device_invitation ( |
| 35 | id uuid primary key default gen_random_uuid(), |
| 36 | family_id uuid not null, |
| 37 | child_user_id uuid not null, |
| 38 | issuer_user_id uuid not null references app_user(id), |
| 39 | token_digest text not null unique check (token_digest ~ '^[a-f0-9]{64}$'), |
| 40 | created_at timestamptz not null default clock_timestamp(), |
| 41 | expires_at timestamptz not null, |
| 42 | used_at timestamptz, |
| 43 | revoked_at timestamptz, |
| 44 | foreign key (family_id,child_user_id) references managed_child(family_id,user_id) on delete cascade |
| 45 | ); |
| 46 | create index child_device_invitation_child_idx on child_device_invitation(child_user_id) |
| 47 | where used_at is null and revoked_at is null; |
| 48 | |
| 49 | create table guardian_invitation ( |
| 50 | id uuid primary key default gen_random_uuid(), |
| 51 | family_id uuid not null, |
| 52 | child_user_id uuid not null, |
| 53 | issuer_user_id uuid not null references app_user(id), |
| 54 | guardian_user_id uuid not null references app_user(id), |
| 55 | token_digest text not null unique check (token_digest ~ '^[a-f0-9]{64}$'), |
| 56 | created_at timestamptz not null default clock_timestamp(), |
| 57 | expires_at timestamptz not null, |
| 58 | used_at timestamptz, |
| 59 | revoked_at timestamptz, |
| 60 | foreign key (family_id,child_user_id) references managed_child(family_id,user_id) on delete cascade, |
| 61 | check (guardian_user_id<>issuer_user_id and guardian_user_id<>child_user_id) |
| 62 | ); |
| 63 | create index guardian_invitation_child_idx on guardian_invitation(child_user_id) |
| 64 | where used_at is null and revoked_at is null; |
| 65 | |
| 66 | revoke all on managed_child,child_consent,child_device_invitation,guardian_invitation from public; |
| 67 | commit; |