CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0008_workflows.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| eafe8c6 | 1 | -- Gluecron migration 0008: Block C1 — Actions-equivalent workflow runner. |
| 2 | -- | |
| 3 | -- Tables: | |
| 4 | -- workflows — parsed workflow YAML files discovered in a repo | |
| 5 | -- workflow_runs — one execution of a workflow, triggered by an event | |
| 6 | -- workflow_jobs — jobs within a run (each is a sequence of steps) | |
| 7 | -- workflow_artifacts — files uploaded by a run (stored in bytea for v1) | |
| 8 | ||
| 9 | --> statement-breakpoint | |
| 10 | CREATE TABLE IF NOT EXISTS "workflows" ( | |
| 11 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | |
| 12 | "repository_id" uuid NOT NULL, | |
| 13 | "name" text NOT NULL, | |
| 14 | "path" text NOT NULL, | |
| 15 | "yaml" text NOT NULL, | |
| 16 | "parsed" text NOT NULL, | |
| 17 | "on_events" text NOT NULL DEFAULT '[]', | |
| 18 | "disabled" boolean DEFAULT false NOT NULL, | |
| 19 | "created_at" timestamp DEFAULT now() NOT NULL, | |
| 20 | "updated_at" timestamp DEFAULT now() NOT NULL, | |
| 21 | CONSTRAINT "workflows_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade | |
| 22 | ); | |
| 23 | ||
| 24 | --> statement-breakpoint | |
| 25 | CREATE INDEX IF NOT EXISTS "workflows_repo" ON "workflows" ("repository_id"); | |
| 26 | --> statement-breakpoint | |
| 27 | CREATE UNIQUE INDEX IF NOT EXISTS "workflows_repo_path" ON "workflows" ("repository_id", "path"); | |
| 28 | ||
| 29 | --> statement-breakpoint | |
| 30 | CREATE TABLE IF NOT EXISTS "workflow_runs" ( | |
| 31 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | |
| 32 | "workflow_id" uuid NOT NULL, | |
| 33 | "repository_id" uuid NOT NULL, | |
| 34 | "run_number" integer NOT NULL, | |
| 35 | "event" text NOT NULL, | |
| 36 | "ref" text, | |
| 37 | "commit_sha" text, | |
| 38 | "triggered_by" uuid, | |
| 39 | "status" text NOT NULL DEFAULT 'queued', | |
| 40 | "conclusion" text, | |
| 41 | "queued_at" timestamp DEFAULT now() NOT NULL, | |
| 42 | "started_at" timestamp, | |
| 43 | "finished_at" timestamp, | |
| 44 | "created_at" timestamp DEFAULT now() NOT NULL, | |
| 45 | CONSTRAINT "workflow_runs_workflow_fk" FOREIGN KEY ("workflow_id") REFERENCES "workflows"("id") ON DELETE cascade, | |
| 46 | CONSTRAINT "workflow_runs_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade, | |
| 47 | CONSTRAINT "workflow_runs_user_fk" FOREIGN KEY ("triggered_by") REFERENCES "users"("id") ON DELETE set null | |
| 48 | ); | |
| 49 | ||
| 50 | --> statement-breakpoint | |
| 51 | CREATE INDEX IF NOT EXISTS "workflow_runs_repo" ON "workflow_runs" ("repository_id"); | |
| 52 | --> statement-breakpoint | |
| 53 | CREATE INDEX IF NOT EXISTS "workflow_runs_status" ON "workflow_runs" ("status"); | |
| 54 | --> statement-breakpoint | |
| 55 | CREATE INDEX IF NOT EXISTS "workflow_runs_workflow" ON "workflow_runs" ("workflow_id"); | |
| 56 | ||
| 57 | --> statement-breakpoint | |
| 58 | CREATE TABLE IF NOT EXISTS "workflow_jobs" ( | |
| 59 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | |
| 60 | "run_id" uuid NOT NULL, | |
| 61 | "name" text NOT NULL, | |
| 62 | "job_order" integer NOT NULL DEFAULT 0, | |
| 63 | "runs_on" text NOT NULL DEFAULT 'default', | |
| 64 | "status" text NOT NULL DEFAULT 'queued', | |
| 65 | "conclusion" text, | |
| 66 | "exit_code" integer, | |
| 67 | "steps" text NOT NULL DEFAULT '[]', | |
| 68 | "logs" text NOT NULL DEFAULT '', | |
| 69 | "started_at" timestamp, | |
| 70 | "finished_at" timestamp, | |
| 71 | "created_at" timestamp DEFAULT now() NOT NULL, | |
| 72 | CONSTRAINT "workflow_jobs_run_fk" FOREIGN KEY ("run_id") REFERENCES "workflow_runs"("id") ON DELETE cascade | |
| 73 | ); | |
| 74 | ||
| 75 | --> statement-breakpoint | |
| 76 | CREATE INDEX IF NOT EXISTS "workflow_jobs_run" ON "workflow_jobs" ("run_id"); | |
| 77 | ||
| 78 | --> statement-breakpoint | |
| 79 | CREATE TABLE IF NOT EXISTS "workflow_artifacts" ( | |
| 80 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | |
| 81 | "run_id" uuid NOT NULL, | |
| 82 | "job_id" uuid, | |
| 83 | "name" text NOT NULL, | |
| 84 | "size_bytes" integer NOT NULL DEFAULT 0, | |
| 85 | "content_type" text DEFAULT 'application/octet-stream' NOT NULL, | |
| 86 | "content" bytea, | |
| 87 | "created_at" timestamp DEFAULT now() NOT NULL, | |
| 88 | CONSTRAINT "workflow_artifacts_run_fk" FOREIGN KEY ("run_id") REFERENCES "workflow_runs"("id") ON DELETE cascade, | |
| 89 | CONSTRAINT "workflow_artifacts_job_fk" FOREIGN KEY ("job_id") REFERENCES "workflow_jobs"("id") ON DELETE set null | |
| 90 | ); | |
| 91 | ||
| 92 | --> statement-breakpoint | |
| 93 | CREATE INDEX IF NOT EXISTS "workflow_artifacts_run" ON "workflow_artifacts" ("run_id"); |