/
PostmenBlake
/
NotificationPreferencesService
Обзор
Документация
Войти
/
PostmenBlake
/
NotificationPreferencesService
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/infrastructure/database/migrations/001_initial.sql
33 строки
1 KB
kurava
feat: initial commit - Notification Preferences Service
17 июн 2026, 09:11
17 июн 2026, 09:11
48825c3
Код
Авторство
О чём код?
-- Create user_preferences table CREATE TABLE IF NOT EXISTS user_preferences ( user_id VARCHAR(255) PRIMARY KEY, preferences JSONB NOT NULL, quiet_hours JSONB, region VARCHAR(50) NOT NULL, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); -- Create global_policies table CREATE TABLE IF NOT EXISTS global_policies ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), notification_type VARCHAR(100) NOT NULL, region VARCHAR(50) NOT NULL, allowed BOOLEAN NOT NULL, reason TEXT, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, UNIQUE(notification_type, region) ); -- Create index for faster lookups CREATE INDEX IF NOT EXISTS idx_user_preferences_user_id ON user_preferences(user_id); CREATE INDEX IF NOT EXISTS idx_global_policies_type_region ON global_policies(notification_type, region); -- Insert default global policies INSERT INTO global_policies (notification_type, region, allowed, reason) VALUES ('marketing_sms', 'EU', false, 'GDPR restrictions on marketing SMS in EU'), ('marketing_email', 'EU', true, 'Marketing email allowed in EU with consent'), ('marketing_push', 'EU', true, 'Marketing push allowed in EU with consent') ON CONFLICT (notification_type, region) DO NOTHING;