-- Attribute every model call to the identity the work was requested as, so -- usage reports can break down by the people and agents that asked for it. -- A task's calls belong to the identity that created the task; chat and -- curator calls carry the calling principal in the record itself, so a queued -- retry keeps its attribution. -- +goose Up ALTER TABLE model_usage ADD COLUMN identity_id text NOT NULL DEFAULT ''; UPDATE model_usage u SET identity_id = t.identity FROM tasks t WHERE u.task_id = t.id AND u.task_id <> 0 AND u.identity_id = ''; -- +goose Down ALTER TABLE model_usage DROP COLUMN identity_id;