| 1 | -- SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | -- |
| 3 | -- Durable public source remotes for repo imports and submodule gitlink |
| 4 | -- hydration. A repo may remember one upstream fetch URL; fetch status is |
| 5 | -- advisory so failed imports can be retried from settings without losing |
| 6 | -- the configured remote. |
| 7 | |
| 8 | -- +goose Up |
| 9 | |
| 10 | CREATE TABLE repo_source_remotes ( |
| 11 | repo_id bigint PRIMARY KEY REFERENCES repos(id) ON DELETE CASCADE, |
| 12 | remote_url text NOT NULL, |
| 13 | last_fetched_at timestamptz, |
| 14 | last_error text, |
| 15 | created_at timestamptz NOT NULL DEFAULT now(), |
| 16 | updated_at timestamptz NOT NULL DEFAULT now(), |
| 17 | CHECK (remote_url <> ''), |
| 18 | CHECK (length(remote_url) <= 2048) |
| 19 | ); |
| 20 | |
| 21 | CREATE TRIGGER repo_source_remotes_set_updated_at |
| 22 | BEFORE UPDATE ON repo_source_remotes |
| 23 | FOR EACH ROW EXECUTE FUNCTION tg_set_updated_at(); |
| 24 | |
| 25 | |
| 26 | -- +goose Down |
| 27 | |
| 28 | DROP TRIGGER IF EXISTS repo_source_remotes_set_updated_at ON repo_source_remotes; |
| 29 | DROP TABLE IF EXISTS repo_source_remotes; |
| 30 |