WellNuo/backend/migrations/004_create_notification_settings.sql
Sergei ec63a2c1e2 Add admin panel, optimized API, OTP auth, migrations
Admin Panel (Next.js):
- Dashboard with stats
- Users list with relationships (watches/watched_by)
- User detail pages
- Deployments list and detail pages
- Devices, Orders, Subscriptions pages
- OTP-based admin authentication

Backend Optimizations:
- Fixed N+1 query problem in admin APIs
- Added pagination support
- Added .range() and count support to Supabase wrapper
- Optimized batch queries with lookup maps

Database:
- Added migrations for schema evolution
- New tables: push_tokens, notification_settings
- Updated access model

iOS Build Scripts:
- build-ios.sh, clear-apple-cache.sh
- EAS configuration updates

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-20 11:05:39 -08:00

44 lines
1.6 KiB
SQL

-- ============================================================
-- Migration: 004_create_notification_settings
-- Date: 2025-12-19
-- Author: Claude
-- Description: Create table for user notification preferences
-- ============================================================
-- UP: Apply migration
-- ============================================================
CREATE TABLE IF NOT EXISTS notification_settings (
user_id INTEGER PRIMARY KEY REFERENCES person_details(user_id) ON DELETE CASCADE,
-- Alert preferences
alerts_enabled BOOLEAN DEFAULT true,
urgent_alerts_enabled BOOLEAN DEFAULT true,
daily_report_enabled BOOLEAN DEFAULT true,
weekly_report_enabled BOOLEAN DEFAULT true,
-- Quiet hours
quiet_hours_enabled BOOLEAN DEFAULT false,
quiet_hours_start TIME DEFAULT '22:00',
quiet_hours_end TIME DEFAULT '07:00',
-- Channel preferences
push_enabled BOOLEAN DEFAULT true,
email_enabled BOOLEAN DEFAULT true,
sms_enabled BOOLEAN DEFAULT false,
-- Timestamps
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Comments
COMMENT ON TABLE notification_settings IS 'Per-user notification preferences';
COMMENT ON COLUMN notification_settings.quiet_hours_enabled IS 'Mute non-urgent notifications during quiet hours';
COMMENT ON COLUMN notification_settings.urgent_alerts_enabled IS 'Urgent alerts (no activity 6+ hours) bypass quiet hours';
-- ============================================================
-- DOWN: Rollback migration (for reference only)
-- ============================================================
-- DROP TABLE IF EXISTS notification_settings;