amber-backend/pb_migrations/1796600000_e2e_runs_updated.js

26 lines
847 B
JavaScript
Raw Permalink Normal View History

/// <reference path="../pb_data/types.d.ts" />
// When a run last moved.
//
// The collection had `created` and nothing else, so "is this run still alive or
// did it die" had no answer: the dashboard read a field that was not there, got
// NaN, and called every live run stalled. `status` alone cannot answer it -- a
// killed process leaves its record saying `running` for ever -- so the honest
// signal is the timestamp of the last update.
migrate(
(app) => {
const runs = app.findCollectionByNameOrId("e2e_runs");
runs.fields.add(
new AutodateField({ name: "updated", onCreate: true, onUpdate: true }),
);
app.save(runs);
},
(app) => {
const runs = app.findCollectionByNameOrId("e2e_runs");
const f = runs.fields.getByName("updated");
if (f) runs.fields.removeById(f.id);
app.save(runs);
},
);