bmc_hub/migrations/1073_work_desk.sql

14 lines
870 B
MySQL
Raw Permalink Normal View History

-- Additive: keep canonical queues, shared events and actual time entries.
ALTER TABLE planner_queue_versions ADD COLUMN IF NOT EXISTS desk_manual_order BOOLEAN NOT NULL DEFAULT FALSE;
DO $$ BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_schema=current_schema() AND table_name='sag_case_assignees' AND column_name='desk_seen_at') THEN
ALTER TABLE sag_case_assignees ADD COLUMN desk_seen_at TIMESTAMPTZ;
-- Existing assignments are known; only subsequent assignments enter the inbox.
UPDATE sag_case_assignees SET desk_seen_at=assigned_at AT TIME ZONE 'UTC';
END IF;
END $$;
ALTER TABLE tmodule_times ADD COLUMN IF NOT EXISTS planner_event_id BIGINT REFERENCES planner_events(id);
CREATE UNIQUE INDEX IF NOT EXISTS tmodule_event_participant_once
ON tmodule_times(planner_event_id,medarbejder_id) WHERE planner_event_id IS NOT NULL;