-- Who performed an assignment (terdut-server#35). On an 'assigned' event -- incident_events.user_id is the assignee, so the actor needs columns of its -- own. Only populated for 'assigned' events; every other event type keeps -- using user_id/service_account_id for the actor. Older 'assigned' rows stay -- NULL (the actor was never recorded). Same shape as migration 015: nullable, -- mutually exclusive, ON DELETE SET NULL. -- -- assigned_to_service_account_id is still deliberately not added: making -- service accounts assignable is a separate change (request body, assignee -- picker, notifier, filters). ALTER TABLE incident_events ADD COLUMN actor_user_id BIGINT REFERENCES users(id) ON DELETE SET NULL, ADD COLUMN actor_service_account_id BIGINT REFERENCES service_accounts(id) ON DELETE SET NULL; ALTER TABLE incident_events ADD CONSTRAINT incident_events_assign_actor_xor_chk CHECK ( actor_user_id IS NULL OR actor_service_account_id IS NULL ); CREATE INDEX incident_events_actor_user_id_idx ON incident_events(actor_user_id); CREATE INDEX incident_events_actor_service_account_id_idx ON incident_events(actor_service_account_id);