| 1 | -- SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | -- |
| 3 | -- Per-workflow enable/disable knob for the §13 REST surface. |
| 4 | -- |
| 5 | -- We don't have a `workflows` table (workflows are discovered from |
| 6 | -- the git tree on demand), so the discriminator here is the |
| 7 | -- repo-relative path (e.g. ".shithub/workflows/ci.yml"). One row per |
| 8 | -- disabled workflow file; absence of a row means the workflow runs |
| 9 | -- normally. |
| 10 | -- |
| 11 | -- The trigger pipeline consults this table on every event: a disabled |
| 12 | -- workflow's runs are not enqueued. Re-enabling (DELETE the row) is |
| 13 | -- the inverse — the next matching event resumes triggering as |
| 14 | -- normal. This is intentionally a flag, not an audit log; the |
| 15 | -- `audit_log` table records the actor + reason for the operator |
| 16 | -- forensics path. |
| 17 | |
| 18 | -- +goose Up |
| 19 | CREATE TABLE workflow_disabled ( |
| 20 | repo_id bigint NOT NULL REFERENCES repos(id) ON DELETE CASCADE, |
| 21 | workflow_file text NOT NULL, |
| 22 | disabled_by_user_id bigint REFERENCES users(id) ON DELETE SET NULL, |
| 23 | disabled_at timestamptz NOT NULL DEFAULT now(), |
| 24 | |
| 25 | PRIMARY KEY (repo_id, workflow_file), |
| 26 | CONSTRAINT workflow_disabled_file_format |
| 27 | CHECK (workflow_file LIKE '.shithub/workflows/%') |
| 28 | ); |
| 29 | |
| 30 | CREATE INDEX workflow_disabled_repo_id_idx |
| 31 | ON workflow_disabled (repo_id); |
| 32 | |
| 33 | -- +goose Down |
| 34 | DROP TABLE IF EXISTS workflow_disabled; |
| 35 |