LifeMate — Personal, Family & Learning Companion
infra/cloudflare-neon-migration
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 | # Cloudflare Workers + Neon PostgreSQL migration |
| 2 | |
| 3 | ## Target |
| 4 | Life Guide clients -> Cloudflare Workers API -> Neon PostgreSQL. Railway remains rollback-only until the new path passes staging verification. |
| 5 | |
| 6 | ## Required secrets |
| 7 | Configure these as Cloudflare Worker secrets, never client variables: |
| 8 | - NEON_DATABASE_URL: pooled Neon PostgreSQL connection string with TLS. |
| 9 | - JWT_SECRET: existing production JWT signing secret, minimum 32 characters. |
| 10 | - RESEND_API_KEY when transactional email is enabled. |
| 11 | |
| 12 | Configure CORS_ORIGINS, PUBLIC_APP_URL and EMAIL_FROM as environment variables appropriate to the deployed application. |
| 13 | |
| 14 | ## Database migration |
| 15 | 1. Freeze schema-changing deployments during cutover. |
| 16 | 2. Create a Neon project/database and obtain the pooled PostgreSQL connection string. |
| 17 | 3. Take a fresh Railway PostgreSQL backup with pg_dump in custom format. |
| 18 | 4. Restore into Neon with pg_restore. |
| 19 | 5. Run the repository migrations against Neon and verify all migrations are applied. |
| 20 | 6. Compare critical row counts and constraints for identity, profiles, families, memberships, guardians, sessions, planner, school, learning and wellbeing data. |
| 21 | 7. Keep the Railway database intact and read-only/rollback-capable until acceptance checks pass. |
| 22 | |
| 23 | Example operator commands (credentials supplied securely by the operator): |
| 24 | |
| 25 | pg_dump --format=custom --no-owner --no-acl "$RAILWAY_DATABASE_URL" > lifeguide-cutover.dump |
| 26 | pg_restore --clean --if-exists --no-owner --no-acl --dbname "$NEON_DATABASE_URL" lifeguide-cutover.dump |
| 27 | DATABASE_URL="$NEON_DATABASE_URL" npm run migrate |
| 28 | |
| 29 | ## Cloudflare Workers deployment |
| 30 | The Worker entrypoint is backend/src/worker.js and deployment configuration is backend/wrangler.jsonc. It reuses the existing Express API through Cloudflare's Node HTTP server adapter. PostgreSQL remains behind the server API; no database credentials are exposed to Flutter or the PWA. |
| 31 | |
| 32 | Before deployment set Worker secrets NEON_DATABASE_URL and JWT_SECRET. Use the existing JWT secret during migration so valid sessions are not invalidated solely by infrastructure cutover. |
| 33 | |
| 34 | ## Acceptance checks |
| 35 | - /live returns 200. |
| 36 | - /ready returns 200 and database=ready. |
| 37 | - /health returns 200 against Neon. |
| 38 | - Authentication registration/verification/login/refresh/recovery tests pass. |
| 39 | - Family create/invite/guardian authorization tests pass. |
| 40 | - Planner, school, learning, wellbeing and privacy-boundary tests pass. |
| 41 | - PWA and Android staging clients use the Cloudflare API endpoint successfully. |
| 42 | - CORS permits only approved origins. |
| 43 | - Logs contain no database URLs, tokens, passwords or minor-sensitive content. |
| 44 | |
| 45 | ## Cutover and rollback |
| 46 | Do not delete Railway before acceptance. Point staging clients to Cloudflare first. After successful end-to-end verification, change production API routing to Cloudflare. Keep Railway available for a defined rollback window. If critical API/database verification fails, restore the previous client/API route to Railway and investigate without modifying the Neon copy destructively. |
| 47 | |
| 48 | Railway removal is the final cleanup step only after the Cloudflare Workers + Neon PostgreSQL path is verified and explicit production cutover approval has been given. |