| 1 | CREATE TABLE operator_plans ( |
| 2 | plan_id TEXT PRIMARY KEY CHECK(length(plan_id)=43 AND plan_id NOT GLOB '*[^a-zA-Z0-9_-]*'), |
| 3 | state TEXT NOT NULL UNIQUE CHECK(state IN ('pending','open')), |
| 4 | kind TEXT NOT NULL CHECK(kind IN ('initialize','create-team','add-apps','retire-apps')), |
| 5 | label TEXT CHECK(label IS NULL OR (length(label) BETWEEN 1 AND 63 AND label NOT GLOB '*[^a-z0-9-]*')), |
| 6 | apps TEXT NOT NULL CHECK(length(apps)<=256 AND apps NOT GLOB '*[^a-z,]*'), |
| 7 | sealed_name BLOB CHECK(sealed_name IS NULL OR (typeof(sealed_name)='blob' AND length(sealed_name) BETWEEN 29 AND 284)), |
| 8 | expires_at INTEGER NOT NULL CHECK(typeof(expires_at)='integer' AND expires_at>0), |
| 9 | window_expires_at INTEGER CHECK(window_expires_at IS NULL OR (typeof(window_expires_at)='integer' AND window_expires_at>0)), |
| 10 | CHECK((kind='initialize') = (label IS NULL)), |
| 11 | CHECK((kind='initialize') = (apps='')), |
| 12 | CHECK((kind='create-team') = (sealed_name IS NOT NULL)), |
| 13 | CHECK((state='open') = (window_expires_at IS NOT NULL)) |
| 14 | ); |
| 15 | -- The provenance fence: teams whose seed committed through the HTTP stream. |
| 16 | CREATE TABLE operator_http_teams ( |
| 17 | team_id INTEGER PRIMARY KEY REFERENCES teams(id), |
| 18 | operation_id TEXT NOT NULL UNIQUE REFERENCES directory_operator_results(operation_id) DEFERRABLE INITIALLY DEFERRED |
| 19 | ); |
| 20 | |