bmc_hub/migrations/1042_user_sag_module_prefs.sql
Christian 81b8229db1 feat: Add Kuando Busylight integration and enhance case creation UI
- Introduced Kuando Busylight integration for centralized presence management.
- Updated case creation UI to support new modules and improved type handling.
- Added personal Buzzwords visibility preferences for users.
- Implemented file upload functionality directly from the case topbar.
- Enhanced validation and user experience in case creation process.
- Created migration for user-specific module preferences.
- Updated tests to cover new features and ensure functionality.
2026-09-23 00:23:30 +02:00

31 lines
1.2 KiB
PL/PgSQL

-- Migration 1042: Per-user visibility preferences for case modules.
-- Existing sag_module_prefs remain case-wide for backwards compatibility.
-- New per-user preferences are initially used for the Buzzwords module only.
CREATE TABLE IF NOT EXISTS user_sag_module_prefs (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
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 (user_id, sag_id, module_key)
);
CREATE INDEX IF NOT EXISTS idx_user_sag_module_prefs_user_sag
ON user_sag_module_prefs(user_id, sag_id);
CREATE OR REPLACE FUNCTION update_user_sag_module_prefs_updated_at()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS update_user_sag_module_prefs_updated_at ON user_sag_module_prefs;
CREATE TRIGGER update_user_sag_module_prefs_updated_at
BEFORE UPDATE ON user_sag_module_prefs
FOR EACH ROW
EXECUTE FUNCTION update_user_sag_module_prefs_updated_at();