/// // Adds a `role` select field (admin | user) to the `users` auth collection. // Drives PilotVault's user-rights model: admins can add/remove users; the API // Server reads this field from the caller's token to gate admin endpoints. // Missing/empty role is treated as "user" by the app. // // Apply by copying this file into your PocketBase deployment's `pb_migrations/` // directory and restarting PocketBase. Written for PocketBase v0.22+/v0.23. migrate( (app) => { const users = app.findCollectionByNameOrId('users') users.fields.add( new Field({ name: 'role', type: 'select', required: false, presentable: false, maxSelect: 1, values: ['admin', 'user'], }), ) app.save(users) }, (app) => { const users = app.findCollectionByNameOrId('users') users.fields.removeByName('role') app.save(users) }, )