conductor

CI task system
git clone git://git.finwo.net/app/conductor
Log | Files | Refs | README | LICENSE

002_ownership.sql (1598B)


      1 -- 002_ownership.sql - project ownership and run visibility (sqlite)
      2 --
      3 -- Two changes that go together:
      4 --
      5 --   Ownership. A user may register their own projects and their own
      6 --   workers. A worker that has an owner will only ever be offered jobs
      7 --   belonging to that owner's projects, so lending someone build capacity
      8 --   does not expose anything else. A worker with no owner is shared and
      9 --   can run any project, which is how an administrator provides general
     10 --   capacity.
     11 --
     12 --   Visibility. A run is private unless it says otherwise. The value comes
     13 --   from the project, and the pipeline at the built commit may override it,
     14 --   so a repository decides whether its own results are public.
     15 --
     16 -- Deleting a user deletes what they owned, cascading on to their runs,
     17 -- jobs and artifacts. Leaving the rows behind unowned would be worse than
     18 -- losing them: an unowned project is administered centrally, and an
     19 -- unowned worker token is shared capacity that accepts every project's
     20 -- jobs, so a deleted account would quietly widen a worker's reach rather
     21 -- than removing it.
     22 
     23 ALTER TABLE projects ADD COLUMN owner_id TEXT REFERENCES users(id) ON DELETE CASCADE;
     24 ALTER TABLE projects ADD COLUMN visibility TEXT NOT NULL DEFAULT 'private';
     25 
     26 ALTER TABLE worker_tokens ADD COLUMN owner_id TEXT REFERENCES users(id) ON DELETE CASCADE;
     27 
     28 ALTER TABLE runs ADD COLUMN visibility TEXT NOT NULL DEFAULT 'private';
     29 
     30 CREATE INDEX idx_projects_owner ON projects (owner_id);
     31 CREATE INDEX idx_worker_tokens_owner ON worker_tokens (owner_id);
     32 CREATE INDEX idx_runs_visibility ON runs (visibility);