| 1 | -- An agent is on teams the way a person is: through team membership in |
| 2 | -- identity (team_agents), added and removed on the team page or the |
| 3 | -- agent's profile (docs.g1t.sh/guides/people-and-teams/). The agent itself |
| 4 | -- carries no team and no department. |
| 5 | -- |
| 6 | -- agents.team and agents.department stay as they are, unused: migrations |
| 7 | -- run before the code, so the code still serving during a deploy reads |
| 8 | -- and writes them for a minute or more. A later migration drops them once |
| 9 | -- no deployed code names them. |
| 10 | -- |
| 11 | -- Each agent's old `team` moves to a membership once (src/team-move.ts, |
| 12 | -- run by the cron): a team of that slug in its workspace gets it as a |
| 13 | -- member, and a value that names no team is dropped and logged. |
| 14 | -- `team_moved_at` marks the agents it has seen, so it never runs twice for |
| 15 | -- one, and taking an agent off that team later stays taken off. |
| 16 | ALTER TABLE agents ADD COLUMN team_moved_at TEXT; |
| 17 | CREATE INDEX IF NOT EXISTS agents_team_to_move ON agents (id) WHERE team IS NOT NULL AND team <> '' AND team_moved_at IS NULL; |