g1t/services/repos/migrations/0009_lifecycle.sql
| 1 | -- A repository's lifecycle beyond create and transfer: its home page, |
| 2 | -- archiving, and deleting with a window to restore. See src/lifecycle.rs. |
| 3 | -- |
| 4 | -- website: an http(s) address shown beside its description. |
| 5 | -- archived_at: set while it is read-only (pushes, merges, agents and |
| 6 | -- workflows refused; issues and pull requests locked). |
| 7 | -- deleted_at / deleted_by / purge_after: set while it is deleted. A deleted |
| 8 | -- repository is hidden from every read, git refuses it, and its name stays |
| 9 | -- taken; restoring clears the three. The hourly sweep purges it once |
| 10 | -- purge_after has passed: its git data, its row and its redirects go, and |
| 11 | -- every service drops what it keeps for it on `repo.purged`. |
| 12 | ALTER TABLE repos ADD COLUMN website TEXT; |
| 13 | ALTER TABLE repos ADD COLUMN archived_at TEXT; |
| 14 | ALTER TABLE repos ADD COLUMN deleted_at TEXT; |
| 15 | ALTER TABLE repos ADD COLUMN deleted_by TEXT; |
| 16 | ALTER TABLE repos ADD COLUMN purge_after TEXT; |
| 17 | CREATE INDEX IF NOT EXISTS repos_purge ON repos (purge_after) WHERE deleted_at IS NOT NULL; |
| 18 | |
| 19 | -- A branch renamed keeps its old name here, pointing at the new one, so web |
| 20 | -- addresses that name it (tree/<branch>/..., commits?ref=) redirect. A |
| 21 | -- redirect stops when a branch of the old name is made again (checked when |
| 22 | -- it is read) or the repository is purged. |
| 23 | CREATE TABLE IF NOT EXISTS branch_redirects ( |
| 24 | repo_id TEXT NOT NULL, |
| 25 | branch TEXT NOT NULL, |
| 26 | now TEXT NOT NULL, |
| 27 | created_at TEXT NOT NULL, |
| 28 | PRIMARY KEY (repo_id, branch) |
| 29 | ); |