Split the automatic logging path by the app that logged the flight
logging_path is now manual, automatic_flyapp or automatic_flyagentapp. The Fly App's entries are backed by the aircraft's flight recorder and keep the missing-FDR red flag; the Fly Agent App's come from Remote ID, which is not a flight recorder, so they must carry the § 5 fields like a manual entry. The API maps the old "automatic" onto automatic_flyapp so Fly App builds already on devices keep filing. The migration has been applied to the remote PocketBase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3dd31b257a
commit
bc41d8b128
12 files changed
+242
-50
No files matched your search
@@ -0,0 +1,60 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
// Splits the flights' `logging_path` "automatic" by which app logged it, since
|
||||
// there are now two and they are not equally trustworthy:
|
||||
//
|
||||
// manual typed in by the pilot (Web App form)
|
||||
// automatic_flyapp Fly App, from the aircraft's own telemetry over the
|
||||
// DJI SDK; backed by the FDR log
|
||||
// automatic_flyagentapp Fly Agent App, from the aircraft's Remote ID
|
||||
// broadcast; no FDR, so the API Server still requires
|
||||
// the § 5 minimum fields on it
|
||||
//
|
||||
// Every existing "automatic" record was logged by the Fly App (the only app
|
||||
// that logged automatically before this), so it becomes "automatic_flyapp".
|
||||
// The API Server also maps an incoming "automatic" onto "automatic_flyapp",
|
||||
// so Fly App builds already on devices keep filing.
|
||||
//
|
||||
// Apply by copying into your PocketBase deployment's `pb_migrations/` directory
|
||||
// and restarting. Written for PocketBase v0.22+/v0.23. Idempotent: the values
|
||||
// are set outright and only records still holding "automatic" are rewritten.
|
||||
//
|
||||
// Depends on 1720300700_add_logbook.js.
|
||||
migrate(
|
||||
(app) => {
|
||||
const flights = app.findCollectionByNameOrId('flights')
|
||||
const field = flights.fields.find((f) => f.name === 'logging_path')
|
||||
|
||||
// Widen first, so records can move to the new value before the old one goes.
|
||||
field.values = ['manual', 'automatic', 'automatic_flyapp', 'automatic_flyagentapp']
|
||||
app.save(flights)
|
||||
|
||||
for (const rec of app.findRecordsByFilter('flights', "logging_path = 'automatic'", '', 0, 0)) {
|
||||
rec.set('logging_path', 'automatic_flyapp')
|
||||
app.save(rec)
|
||||
}
|
||||
|
||||
field.values = ['manual', 'automatic_flyapp', 'automatic_flyagentapp']
|
||||
app.save(flights)
|
||||
},
|
||||
(app) => {
|
||||
const flights = app.findCollectionByNameOrId('flights')
|
||||
const field = flights.fields.find((f) => f.name === 'logging_path')
|
||||
|
||||
field.values = ['automatic', 'manual', 'automatic_flyapp', 'automatic_flyagentapp']
|
||||
app.save(flights)
|
||||
|
||||
// The old schema has one automatic value, so both apps fold back into it.
|
||||
for (const rec of app.findRecordsByFilter(
|
||||
'flights',
|
||||
"logging_path = 'automatic_flyapp' || logging_path = 'automatic_flyagentapp'",
|
||||
'', 0, 0,
|
||||
)) {
|
||||
rec.set('logging_path', 'automatic')
|
||||
app.save(rec)
|
||||
}
|
||||
|
||||
field.values = ['automatic', 'manual']
|
||||
app.save(flights)
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user