WellNuo/backend/migrations/008_update_notification_settings.sql
Sergei fe4ff1a932 Simplify DB schema (name/address single fields) + subscription flow
Database:
- Simplified beneficiary schema: single `name` field instead of first_name/last_name
- Single `address` field instead of 5 separate address columns
- Added migration 008_update_notification_settings.sql

Backend:
- Updated all beneficiaries routes for new schema
- Fixed admin routes for simplified fields
- Updated notification settings routes
- Improved stripe and webhook handlers

Frontend:
- Updated all forms to use single name/address fields
- Added new equipment-status and purchase screens
- Added BeneficiaryDetailController service
- Added subscription service
- Improved navigation and auth flow
- Various UI improvements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 10:35:15 -08:00

42 lines
1.9 KiB
SQL

-- ============================================================
-- Migration: 008_update_notification_settings
-- Date: 2025-01-04
-- Author: Claude
-- Description: Add new notification setting columns for mobile app
-- ============================================================
-- UP: Apply migration
-- ============================================================
-- Add new columns for alert types
ALTER TABLE notification_settings
ADD COLUMN IF NOT EXISTS emergency_alerts BOOLEAN DEFAULT true,
ADD COLUMN IF NOT EXISTS activity_alerts BOOLEAN DEFAULT true,
ADD COLUMN IF NOT EXISTS low_battery BOOLEAN DEFAULT true,
ADD COLUMN IF NOT EXISTS daily_summary BOOLEAN DEFAULT false,
ADD COLUMN IF NOT EXISTS weekly_summary BOOLEAN DEFAULT true;
-- Migrate existing data if needed (optional - map old to new)
UPDATE notification_settings SET
emergency_alerts = COALESCE(urgent_alerts_enabled, true),
daily_summary = COALESCE(daily_report_enabled, true),
weekly_summary = COALESCE(weekly_report_enabled, true)
WHERE emergency_alerts IS NULL;
-- Comments
COMMENT ON COLUMN notification_settings.emergency_alerts IS 'Falls, inactivity, SOS button alerts';
COMMENT ON COLUMN notification_settings.activity_alerts IS 'Unusual activity pattern alerts';
COMMENT ON COLUMN notification_settings.low_battery IS 'Device battery warnings';
COMMENT ON COLUMN notification_settings.daily_summary IS 'Daily wellness report';
COMMENT ON COLUMN notification_settings.weekly_summary IS 'Weekly health digest';
-- ============================================================
-- DOWN: Rollback migration (for reference only)
-- ============================================================
-- ALTER TABLE notification_settings
-- DROP COLUMN IF EXISTS emergency_alerts,
-- DROP COLUMN IF EXISTS activity_alerts,
-- DROP COLUMN IF EXISTS low_battery,
-- DROP COLUMN IF EXISTS daily_summary,
-- DROP COLUMN IF EXISTS weekly_summary;