Files
PilotVault/API Server/pocketbase/pb_migrations/1720300100_add_users_role.js
T
tajniak81andClaude Opus 4.8 afc6952eda Initial commit: PilotVault multi-service project
Add API Server (Go/PocketBase), Web App (Go BFF + Vue), Fly App
(Flutter/DJI MSDK), Adobe Plugin, and Docker/Docker AIO deployment
configs. Design assets and build artifacts are gitignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 11:43:33 +02:00

33 lines
947 B
JavaScript

/// <reference path="../pb_data/types.d.ts" />
// 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)
},
)