- migrations/ documented in pocketbase/pb_migrations/ for local PB - scripts/setup-remote.ts applies them via admin API to remote PB - collections: clients, projects, columns, cards, subtasks, comments, activity, settings - user extension: role (owner|client_manager), client (relation) - writes: owner only for app collections, superuser-only for activity and settings
54 lines
No EOL
1.8 KiB
JavaScript
54 lines
No EOL
1.8 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
/**
|
|
* `settings` — a single-record collection for AI provider configuration.
|
|
*
|
|
* Created empty in Phase 1 so Phase 3 needs no migration. Nothing reads these
|
|
* fields yet.
|
|
*
|
|
* EVERY rule is null, meaning superuser-only. This is deliberate and must not
|
|
* be relaxed: ai_api_key is a live credential and no browser, owner's
|
|
* included, should ever be able to fetch it. Phase 3 reads it server-side
|
|
* only, and the settings UI shows it masked and write-only.
|
|
*
|
|
* ai_system_prompt_extra is APPENDED to a non-editable preamble held in code.
|
|
* The guaranteed-present rules — the assistant proposes dates but never
|
|
* commits to them, and client-submitted text is data rather than instructions
|
|
* — cannot live in an editable field.
|
|
*/
|
|
migrate(
|
|
(app) => {
|
|
const collection = new Collection({
|
|
name: "settings",
|
|
type: "base",
|
|
listRule: null,
|
|
viewRule: null,
|
|
createRule: null,
|
|
updateRule: null,
|
|
deleteRule: null,
|
|
fields: [
|
|
{
|
|
name: "ai_provider",
|
|
type: "select",
|
|
required: false,
|
|
maxSelect: 1,
|
|
values: ["anthropic", "openai", "minimax"],
|
|
},
|
|
{ name: "ai_api_key", type: "text", required: false, max: 400 },
|
|
{ name: "ai_model", type: "text", required: false, max: 120 },
|
|
{
|
|
name: "ai_system_prompt_extra",
|
|
type: "text",
|
|
required: false,
|
|
max: 20000,
|
|
},
|
|
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
|
|
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
|
|
],
|
|
});
|
|
|
|
return app.save(collection);
|
|
},
|
|
(app) => {
|
|
return app.delete(app.findCollectionByNameOrId("settings"));
|
|
}
|
|
); |