1-- Per-namespace opt-in for uploads from pull_request runs whose base is the registered branch.
2-- Off by default: such uploads run unreviewed PR code, and default-branch builds restore their entries.
3ALTER TABLE scopes ADD COLUMN pull_requests INTEGER NOT NULL DEFAULT 0 CHECK (pull_requests IN (0, 1));
4
5-- Turning the opt-in off must also invalidate uploads that captured the previous policy.
6DROP TRIGGER changed_policy;
7CREATE TRIGGER changed_policy AFTER UPDATE OF endpoint, repository_id, repository_owner_id, branch,
8 enabled, writes_enabled, pull_requests, retention_seconds, byte_limit, entry_limit, association_limit ON scopes
9WHEN NEW.policy_version = OLD.policy_version
10BEGIN
11 UPDATE scopes SET policy_version = OLD.policy_version + 1 WHERE scope_id = NEW.scope_id;
12END;