/// // items.priority: where an item comes in Shop blocks under "Recommended" // (the default order). Higher comes first; equal priorities go by name. // Empty reads back as 0, so every existing item starts at 0 and the shop // keeps its old alphabetical order until priorities are set. function find(app, name) { try { return app.findCollectionByNameOrId(name); } catch (e) { return null; // fresh install: pb_schema.json (already with the field) is imported later } } migrate( (app) => { const items = find(app, 'items'); if (!items || items.fields.getByName('priority')) return; items.fields.add(new NumberField({ id: 'num_itempriority', name: 'priority', min: -1000, max: 1000, onlyInt: true })); app.save(items); }, (app) => { const items = find(app, 'items'); if (!items || !items.fields.getByName('priority')) return; items.fields.removeByName('priority'); app.save(items); } );