bmc_hub/migrations/093_sag_module_prefs.sql
Christian b43e9f797d feat: Add reminder system for sag cases with user preferences and notification channels
- Implemented user notification preferences table for managing default notification settings.
- Created sag_reminders table to define reminder rules with various trigger types and recipient configurations.
- Developed sag_reminder_queue for processing reminder events triggered by status changes or scheduled times.
- Added sag_reminder_logs to track reminder notifications and user interactions.
- Introduced frontend notification system using Bootstrap 5 Toast for displaying reminders.
- Created email template for sending reminders with case details and action links.
- Implemented rate limiting for user notifications to prevent spamming.
- Added triggers and functions for automatic updates and reminder processing.
2026-02-06 10:47:14 +01:00

28 lines
907 B
PL/PgSQL

-- Migration 093: Case module visibility preferences
CREATE TABLE IF NOT EXISTS sag_module_prefs (
id SERIAL PRIMARY KEY,
sag_id INTEGER NOT NULL REFERENCES sag_sager(id) ON DELETE CASCADE,
module_key VARCHAR(50) NOT NULL,
is_enabled BOOLEAN NOT NULL DEFAULT TRUE,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE (sag_id, module_key)
);
CREATE INDEX IF NOT EXISTS idx_sag_module_prefs_sag ON sag_module_prefs(sag_id);
-- Trigger to auto-update updated_at
CREATE OR REPLACE FUNCTION update_sag_module_prefs_updated_at()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS update_sag_module_prefs_updated_at ON sag_module_prefs;
CREATE TRIGGER update_sag_module_prefs_updated_at
BEFORE UPDATE ON sag_module_prefs
FOR EACH ROW
EXECUTE FUNCTION update_sag_module_prefs_updated_at();