LifeMate — Personal, Family & Learning Companion

docs/offline-data-rescue-options
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 38 lines 1.99 KB
Raw
1 begin;
2
3 create table planner_series (
4 id uuid primary key,
5 owner_user_id uuid not null references app_user(id) on delete cascade,
6 title text not null check (char_length(title) between 1 and 240),
7 kind plan_item_kind not null check (kind in ('task','event','routine')),
8 timezone text not null check (char_length(timezone) between 1 and 100),
9 starts_on date not null,
10 until_on date,
11 frequency text not null check (frequency in ('daily','weekly')),
12 interval_days smallint not null check (interval_days in (1,2)),
13 slots jsonb not null check (jsonb_typeof(slots)='array'),
14 reminder_minutes integer[] not null default '{}',
15 request_hash text not null check (request_hash ~ '^[a-f0-9]{64}$'),
16 materialized_through date,
17 version bigint not null default 1,
18 archived_at timestamptz,
19 created_at timestamptz not null default now(),
20 updated_at timestamptz not null default now(),
21 unique(id,owner_user_id),
22 check (until_on is null or until_on>=starts_on),
23 check (frequency<>'weekly' or interval_days=1)
24 );
25 create index planner_series_owner_idx on planner_series(owner_user_id,created_at) where archived_at is null;
26
27 alter table plan_item add column ends_at timestamptz;
28 alter table plan_item add constraint plan_item_end_order check (ends_at is null or (starts_at is not null and ends_at>starts_at));
29 alter table plan_item add column series_id uuid;
30 alter table plan_item add column original_occurrence_date date;
31 alter table plan_item add constraint plan_item_series_owner_fk foreign key(series_id,owner_user_id)
32 references planner_series(id,owner_user_id) on delete cascade;
33 alter table plan_item add constraint plan_item_series_date_pair check ((series_id is null)=(original_occurrence_date is null));
34 alter table plan_item add constraint plan_item_series_private check (series_id is null or (visibility='private' and family_id is null));
35 alter table plan_item add constraint plan_item_series_occurrence_unique unique(series_id,original_occurrence_date);
36
37 revoke all on planner_series from public;
38 commit;