| 1 | -- Groups gain their own settings: a manual flag (manual groups persist; auto |
| 2 | -- groups are garbage-collected when empty), a visibility, and collaborators |
| 3 | -- whose access cascades to every repository in the group's subtree. |
| 4 | ALTER TABLE groups ADD COLUMN manual BOOLEAN NOT NULL DEFAULT FALSE; |
| 5 | -- Auto/intermediate groups default to 'public' so they impose no visibility |
| 6 | -- ceiling; only a deliberately-restricted group locks the repos beneath it. |
| 7 | ALTER TABLE groups ADD COLUMN visibility TEXT NOT NULL DEFAULT 'public'; |
| 8 | |
| 9 | CREATE TABLE group_collaborators ( |
| 10 | id TEXT PRIMARY KEY, |
| 11 | group_id TEXT NOT NULL REFERENCES groups(id) ON DELETE CASCADE, |
| 12 | user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, |
| 13 | permission TEXT NOT NULL, |
| 14 | created_at BIGINT NOT NULL |
| 15 | ); |
| 16 | CREATE UNIQUE INDEX idx_group_collab ON group_collaborators (group_id, user_id); |