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>
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
|
|
// Creates the `organizations` collection. PilotVault scopes admins to a single
|
|
// organization; a superadmin spans all of them. Users may belong to no org.
|
|
//
|
|
// The API Server reaches this collection only through its superuser service
|
|
// account (like `users` management), so the collection API rules are left locked
|
|
// (superusers only). Apply by copying into your PocketBase deployment's
|
|
// `pb_migrations/` directory and restarting. Written for PocketBase v0.22+/v0.23.
|
|
//
|
|
// Idempotent: if the collection already exists (e.g. it was provisioned live via
|
|
// the admin API), this migration is a no-op.
|
|
migrate(
|
|
(app) => {
|
|
try {
|
|
app.findCollectionByNameOrId('organizations')
|
|
return // already present
|
|
} catch (_) {
|
|
// not found → create it
|
|
}
|
|
|
|
const collection = new Collection({
|
|
type: 'base',
|
|
name: 'organizations',
|
|
fields: [
|
|
{ name: 'name', type: 'text', required: true, max: 120, presentable: true },
|
|
{ name: 'created', type: 'autodate', onCreate: true, onUpdate: false },
|
|
{ name: 'updated', type: 'autodate', onCreate: true, onUpdate: true },
|
|
],
|
|
indexes: ['CREATE UNIQUE INDEX `idx_org_name` ON `organizations` (`name`)'],
|
|
})
|
|
|
|
app.save(collection)
|
|
},
|
|
(app) => {
|
|
try {
|
|
const c = app.findCollectionByNameOrId('organizations')
|
|
app.delete(c)
|
|
} catch (_) {
|
|
// already gone
|
|
}
|
|
},
|
|
)
|