g1t/services/work/migrations/0024_g1t_name.sql
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-agent | 1 | -- 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. | |
| 7 | UPDATE issues SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent'; | |
| 8 | UPDATE pulls SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent'; | |
| 9 | UPDATE comments SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent'; | |
| 10 | UPDATE plans SET author_name = 'g1t' WHERE author_name = 'g1t-agent' OR author_id = 'usr_g1t_agent'; | |
| 11 | UPDATE 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`. | |
| 14 | UPDATE pulls SET agent = 'g1t' WHERE agent = 'g1t-agent'; | |
| 15 | UPDATE agent_runs SET agent = 'g1t' WHERE agent = 'g1t-agent'; | |
| 16 | UPDATE agent_runs SET started_by = 'g1t' WHERE started_by = 'g1t-agent'; | |
| 17 | UPDATE pulls SET merged_by = 'g1t' WHERE merged_by = 'g1t-agent'; | |
| 18 | UPDATE queue_entries SET enqueued_by = 'g1t' WHERE enqueued_by = 'g1t-agent'; | |
| 19 | UPDATE memories SET created_by = 'g1t' WHERE created_by = 'g1t-agent'; | |
| 20 | UPDATE 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. | |
| 23 | UPDATE pulls SET reviewers = replace(reviewers, '"g1t-agent"', '"g1t"') WHERE reviewers LIKE '%"g1t-agent"%'; | |
| 24 | UPDATE pulls SET assignees = replace(assignees, '"g1t-agent"', '"g1t"') WHERE assignees LIKE '%"g1t-agent"%'; | |
| 25 | UPDATE issues SET assignees = replace(assignees, '"g1t-agent"', '"g1t"') WHERE assignees LIKE '%"g1t-agent"%'; | |
| 26 | UPDATE 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. | |
| 32 | UPDATE comments | |
| 33 | SET body = replace(replace(replace(body, 'g1t-agents/', char(1)), 'g1t-agent', 'g1t'), char(1), 'g1t-agents/') | |
| 34 | WHERE body LIKE '%g1t-agent%' | |
| 35 | AND (kind = 'event' OR author_id IN ('usr_g1t_agent', 'g1t', 'g1t_policy', 'svc_runner', 'g1t_runner')); | |
| 36 | UPDATE agent_messages | |
| 37 | SET body = replace(replace(replace(body, 'g1t-agents/', char(1)), 'g1t-agent', 'g1t'), char(1), 'g1t-agents/') | |
| 38 | WHERE body LIKE '%g1t-agent%' AND author_id = 'usr_g1t_agent'; | |
| 39 | UPDATE pulls SET stage_detail = replace(stage_detail, 'g1t-agent', 'g1t') WHERE stage_detail LIKE '%g1t-agent%'; |