/// // Adds a `pluginSettings` JSON field to both the `users` auth collection and the // `organizations` collection. It backs the per-user / per-organization layers of // the OpenSky plugin's cascading settings (API Server → Org Admin → User): // { "opensky": { "config": { clientId, clientSecret, plan, bbox }, "enabled": bool } } // The `enabled` flag is only meaningful on `users` (enablement is strictly per-user). // // Apply by copying this file into your PocketBase deployment's `pb_migrations/` // directory and restarting PocketBase (migrations run automatically on boot). // Idempotent: skips a collection whose field is already present. Written for // PocketBase v0.22+/v0.23 (JSVM `migrate((app) => …)` API). migrate( (app) => { for (const name of ['users', 'organizations']) { const col = app.findCollectionByNameOrId(name) if (col.fields.getByName('pluginSettings')) continue col.fields.add( new Field({ name: 'pluginSettings', type: 'json', required: false, presentable: false, maxSize: 100000, // small JSON blob of plugin config }), ) app.save(col) } }, (app) => { for (const name of ['users', 'organizations']) { const col = app.findCollectionByNameOrId(name) col.fields.removeByName('pluginSettings') app.save(col) } }, )