Services: per-service get-ready time (items.bufferMinutes)
Migration adds the field to existing databases; pb_schema.json mirrors it in the 0.23 top-level format (min/onlyInt under "options" is ignored). Edited next to Duration in Services & products. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
This commit is contained in:
parent
13b5f2bbcb
commit
1a71c9db73
6 changed files with 50 additions and 6 deletions
28
pocketbase/pb_migrations/1792800000_items_buffer_minutes.js
Normal file
28
pocketbase/pb_migrations/1792800000_items_buffer_minutes.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
// items.bufferMinutes: the get-ready time a service needs after each
|
||||
// appointment (tidying the room, changing linen). The admin's slot generator
|
||||
// uses it as the default gap between generated slots. Empty = no gap.
|
||||
|
||||
function find(app, name) {
|
||||
try {
|
||||
return app.findCollectionByNameOrId(name);
|
||||
} catch (e) {
|
||||
return null; // fresh install: pb_schema.json (already has the field) is imported later
|
||||
}
|
||||
}
|
||||
|
||||
migrate(
|
||||
(app) => {
|
||||
const collection = find(app, 'items');
|
||||
if (!collection || collection.fields.getByName('bufferMinutes')) return;
|
||||
collection.fields.add(new NumberField({ id: 'num_itembuffer1', name: 'bufferMinutes', min: 0, onlyInt: true }));
|
||||
app.save(collection);
|
||||
},
|
||||
(app) => {
|
||||
const collection = find(app, 'items');
|
||||
if (!collection || !collection.fields.getByName('bufferMinutes')) return;
|
||||
collection.fields.removeByName('bufferMinutes');
|
||||
app.save(collection);
|
||||
}
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue