/// // Adds an `organization` relation field to the `users` auth collection, pointing // at the `organizations` collection. Not required (maxSelect 1), so users may be // org-less. cascadeDelete is false: deleting an org does not delete its members. // // Depends on 1720300200_add_organizations.js. Idempotent: no-op if the field is // already present. Written for PocketBase v0.22+/v0.23. migrate( (app) => { const users = app.findCollectionByNameOrId('users') if (users.fields.getByName('organization')) return const orgs = app.findCollectionByNameOrId('organizations') users.fields.add( new Field({ name: 'organization', type: 'relation', required: false, collectionId: orgs.id, cascadeDelete: false, minSelect: 0, maxSelect: 1, presentable: false, }), ) app.save(users) }, (app) => { const users = app.findCollectionByNameOrId('users') users.fields.removeByName('organization') app.save(users) }, )