amber-backend/pb_migrations/1796600000_e2e_runs_updated.js
Claude 886e2643cf Give a run a timestamp for when it last moved
The collection had 'created' and nothing else, so the card read a field that was
not there, got NaN, and called every live run stalled. status alone cannot answer
'is it still alive' -- a killed process leaves its record saying running for ever
-- so the honest signal is when it last updated.

And PocketBase hands back '2026-09-10 09:42:49.664Z': a space instead of the T,
with the zone already on the end. Appending another Z made every parse NaN.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 11:44:07 +02:00

25 lines
847 B
JavaScript

/// <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);
},
);