g1t/services/work/migrations/0024_g1t_name.sql

39 lines2,779 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent1-- g1t's agent is shown as g1t, the name g1t itself goes by, so what it did
2-- under its old name, g1t-agent, is renamed here the way a workspace
3-- rename moves its rows. Its id, usr_g1t_agent, stays: only the name
4-- changes. Docs links (`/guides/g1t-agents/`) inside text are kept.
5
6-- Whoever it is shown as, wherever an author's name is stored.
7UPDATE issues SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent';
8UPDATE pulls SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent';
9UPDATE comments SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent';
10UPDATE plans SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent';
11UPDATE agent_messages SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent';
12
13-- Which agent made a pull request or ran: `made_by_g1t` reads `pulls.agent`.
14UPDATE pulls SET agent = 'g1t' WHERE agent = 'g1t-agent';
15UPDATE agent_runs SET agent = 'g1t' WHERE agent = 'g1t-agent';
16UPDATE agent_runs SET started_by = 'g1t' WHERE started_by = 'g1t-agent';
17UPDATE pulls SET merged_by = 'g1t' WHERE merged_by = 'g1t-agent';
18UPDATE queue_entries SET enqueued_by = 'g1t' WHERE enqueued_by = 'g1t-agent';
19UPDATE memories SET created_by = 'g1t' WHERE created_by = 'g1t-agent';
20UPDATE memories SET reviewed_by = 'g1t' WHERE reviewed_by = 'g1t-agent';
21
22-- JSON arrays of usernames: g1t among the reviewers is its review asked for.
23UPDATE pulls SET reviewers = replace(reviewers, '"g1t-agent"', '"g1t"') WHERE reviewers LIKE '%"g1t-agent"%';
24UPDATE pulls SET assignees = replace(assignees, '"g1t-agent"', '"g1t"') WHERE assignees LIKE '%"g1t-agent"%';
25UPDATE issues SET assignees = replace(assignees, '"g1t-agent"', '"g1t"') WHERE assignees LIKE '%"g1t-agent"%';
26UPDATE issues SET labels = replace(labels, '"g1t-agent"', '"g1t"') WHERE labels LIKE '%"g1t-agent"%';
27
28-- What g1t wrote itself, and the timeline's events ("sent g1t-agent back
29-- to address the review", "assigned this to g1t-agent"). People's own
30-- comments are theirs and stay as they wrote them. char(1) holds the docs
31-- links' place while the name is replaced.
32UPDATE comments
33SET body = replace(replace(replace(body, 'g1t-agents/', char(1)), 'g1t-agent', 'g1t'), char(1), 'g1t-agents/')
34WHERE body LIKE '%g1t-agent%'
35 AND (kind = 'event' OR author_id IN ('usr_g1t_agent', 'g1t', 'g1t_policy', 'svc_runner', 'g1t_runner'));
36UPDATE agent_messages
37SET body = replace(replace(replace(body, 'g1t-agents/', char(1)), 'g1t-agent', 'g1t'), char(1), 'g1t-agents/')
38WHERE body LIKE '%g1t-agent%' AND author_id = 'usr_g1t_agent';
39UPDATE pulls SET stage_detail = replace(stage_detail, 'g1t-agent', 'g1t') WHERE stage_detail LIKE '%g1t-agent%';