| 1 | -- M2: repository settings and collaborator management. | |
| 2 | ||
| 3 | -- Who granted a collaborator role. The audit log records the action, but the | |
| 4 | -- current state should also say who is responsible for it — an audit trail that | |
| 5 | -- has been trimmed by retention must not lose the answer to "why does this | |
| 6 | -- person have write access". | |
| 7 | ALTER TABLE repo_collaborators | |
| 8 | ADD COLUMN added_by uuid REFERENCES users ON DELETE SET NULL; | |
| 9 | ||
| 10 | -- The default bookmark is protected implicitly (the UI shows it as "always"), | |
| 11 | -- but the hook enforces protection from the `bookmarks` table alone, so the row | |
| 12 | -- has to agree. Backfilled here and maintained by the indexer thereafter. | |
| 13 | UPDATE bookmarks b | |
| 14 | SET protected = true | |
| 15 | FROM repos r | |
| 16 | WHERE r.id = b.repo_id | |
| 17 | AND b.name = r.default_bookmark | |
| 18 | AND b.protected = false; |
18 lines · SQL