| 1 | -- Forks people make into their workspaces (network.rs). Unlike a pull |
| 2 | -- request's working copy (`fork_of`, namespace `pulls`, hidden), a fork is |
| 3 | -- an ordinary repository of its workspace that remembers where it came |
| 4 | -- from, so it can be synced and can open pull requests there. Cleared |
| 5 | -- when the fork is detached, or when its parent changes who can see it. |
| 6 | ALTER TABLE repos ADD COLUMN parent_id TEXT REFERENCES repos(id); |
| 7 | CREATE INDEX repos_parent ON repos(parent_id) WHERE parent_id IS NOT NULL; |
| 8 | -- What it was made a fork of, never cleared: what forks start with |
| 9 | -- (Actions and issues off) holds once it is detached, and its pull |
| 10 | -- requests into the parent still merge. No reference, as the parent may |
| 11 | -- be purged. |
| 12 | ALTER TABLE repos ADD COLUMN forked_from TEXT; |
| 13 | |
| 14 | -- When the hourly sweep last checked that whoever made a private fork can |
| 15 | -- still read its parent (network.rs); a fork whose maker cannot is |
| 16 | -- deleted, restorable for 30 days. |
| 17 | ALTER TABLE repos ADD COLUMN fork_checked_ms INTEGER; |
| 18 | CREATE INDEX repos_private_forks ON repos(fork_checked_ms) WHERE parent_id IS NOT NULL AND is_private = 1; |
| 19 | |
| 20 | -- A private repository's admins let others fork it. Public repositories |
| 21 | -- can always be forked. |
| 22 | ALTER TABLE repos ADD COLUMN allow_forking INTEGER NOT NULL DEFAULT 0; |