g1t/services/projects/src/rename.ts
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.
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 1 | /** |
| 2 | * A workspace renamed: its projects move to the slug it has now. Each | |
| 3 | * statement takes the current slug and one stale slug, and changes nothing | |
| 4 | * once the rows have moved, so a repeated or late delivery is harmless. | |
| 5 | */ | |
| 6 | ||
| 7 | export type Statement = { sql: string; params: string[] }; | |
| 8 | ||
| 9 | export function renameStatements(stale: string[], current: string): Statement[] { | |
| 10 | return stale.flatMap((old) => [ | |
| 11 | // A project of the same slug made under the new name in the moment | |
| 12 | // before this ran keeps its place; the older one stays put and is | |
| 13 | // reported. | |
| 14 | { sql: "UPDATE OR IGNORE projects SET workspace = ? WHERE workspace = ?", params: [current, old] }, | |
| 15 | { sql: "UPDATE projects SET repo_namespace = ? WHERE repo_namespace = ?", params: [current, old] }, | |
| 16 | { sql: "UPDATE OR IGNORE backfilled SET workspace = ? WHERE workspace = ?", params: [current, old] }, | |
| 17 | { sql: "DELETE FROM backfilled WHERE workspace = ?", params: [old] }, | |
| 18 | ]); | |
| 19 | } |