bmc_hub/migrations/1004_sag_recent_cases.sql
Christian 3452472ba9 Add migrations for recent cases, time tracking pause/resume, and user notes
- Created `sag_recent_cases` table to persist recently opened cases per user for quick access in the bottom bar.
- Added pause/resume support in `tmodule_times` by introducing `paused_at` and `pause_total_seconds` columns.
- Established `user_notes` table for personal user notes with indexing for active and updated notes, along with a trigger to update the `updated_at` timestamp on modifications.

Co-authored-by: Copilot <copilot@github.com>
2026-04-24 11:28:12 +02:00

14 lines
580 B
SQL

-- Persist recently opened cases per user for bottom bar quick access
CREATE TABLE IF NOT EXISTS sag_recent_cases (
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,
opened_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
CONSTRAINT uq_sag_recent_cases_user_sag UNIQUE (user_id, sag_id)
);
CREATE INDEX IF NOT EXISTS idx_sag_recent_cases_user_opened
ON sag_recent_cases (user_id, opened_at DESC, id DESC);