| 1 | -- Repository mirrors: outbound (push to a remote) and inbound (pull from a |
| 2 | -- remote). Credentials are stored so the periodic sync can authenticate; prefer |
| 3 | -- a scoped access token over a password. |
| 4 | CREATE TABLE mirrors ( |
| 5 | id TEXT PRIMARY KEY, |
| 6 | repo_id TEXT NOT NULL REFERENCES repos(id) ON DELETE CASCADE, |
| 7 | direction TEXT NOT NULL, -- 'push' | 'pull' |
| 8 | remote_url TEXT NOT NULL, |
| 9 | username TEXT, |
| 10 | secret TEXT, -- password / token (reversible by design) |
| 11 | branch_filter TEXT, -- push only; blank = all branches |
| 12 | interval_secs BIGINT NOT NULL, -- 0 = manual sync only |
| 13 | sync_on_push INTEGER NOT NULL, -- push mirrors: sync after a received push |
| 14 | last_sync_at BIGINT, |
| 15 | last_error TEXT, |
| 16 | created_at BIGINT NOT NULL |
| 17 | ); |
| 18 | CREATE INDEX idx_mirrors_repo ON mirrors (repo_id); |