/** * @param {import("knex").Knex} knex */ export async function up(knex) { await knex.schema.createTable("workflow_runs", (t) => { t.text("id").primary(); t.text("owner").notNullable(); t.text("workflow").notNullable(); t.text("workflow_name"); t.text("trigger_type").notNullable(); t.text("trigger_detail"); t.text("status").notNullable(); t.text("started_at").notNullable(); t.text("finished_at"); t.integer("duration_ms"); t.text("input"); t.text("output"); t.text("error"); t.text("parent_run_id").references("id").inTable("workflow_runs"); t.text("job_id"); t.text("queued_at"); t.integer("workflow_revision"); }); await knex.schema.raw( "CREATE INDEX workflow_runs_owner_started_at_idx ON workflow_runs (owner, started_at DESC)", ); await knex.schema.raw( "CREATE INDEX workflow_runs_workflow_started_at_idx ON workflow_runs (workflow, started_at DESC)", ); await knex.schema.raw( "CREATE INDEX workflow_runs_status_started_at_idx ON workflow_runs (status, started_at DESC)", ); await knex.schema.raw( "CREATE INDEX workflow_runs_job_id_idx ON workflow_runs (job_id)", ); await knex.schema.raw( "CREATE INDEX workflow_runs_workflow_revision_idx ON workflow_runs (workflow, workflow_revision)", ); } /** * @param {import("knex").Knex} knex */ export async function down(knex) { await knex.schema.dropTableIfExists("workflow_runs"); }