Load the real food menu (11 categories, 137 items)
- app/src/data/menu-data.mjs: single source for PB sync + offline fallback - pb/migrations/1788500000_menu_items_v2.js: price number -> text (supports ranges like 449/549), adds group field for veg/non-veg badges - scripts/update-menu.mjs: replaces menu_categories/menu_items in any PocketBase (local dev or https://admin.greatbear.in) - menu cards: category icons when no image, FSSAI-style dietary badge, text prices, optional pairing/tag footer - content.json drops placeholder menu arrays (menu now lives in code)
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate(
|
||||
(app) => {
|
||||
// The real food menu uses text prices ("449/549" for Veg/Chicken variants)
|
||||
// and needs a veg/non-veg badge field. The previous menu_items collection
|
||||
// only held placeholder content, so we recreate it with the final schema.
|
||||
try {
|
||||
const oldCollection = app.findCollectionByNameOrId('menu_items')
|
||||
app.delete(oldCollection)
|
||||
} catch (e) {
|
||||
// collection may not exist on a fresh database — nothing to migrate
|
||||
}
|
||||
|
||||
const collection = new Collection({
|
||||
name: 'menu_items',
|
||||
type: 'base',
|
||||
listRule: '',
|
||||
viewRule: '',
|
||||
createRule: null,
|
||||
updateRule: null,
|
||||
deleteRule: null,
|
||||
fields: [
|
||||
{ name: 'uid', type: 'text', required: true },
|
||||
{ name: 'category', type: 'text', required: true },
|
||||
{ name: 'name', type: 'text', required: true },
|
||||
{ name: 'description', type: 'text' },
|
||||
{ name: 'price', type: 'text' },
|
||||
{ name: 'pairing', type: 'text' },
|
||||
{ name: 'tag', type: 'text' },
|
||||
{ name: 'image', type: 'text' },
|
||||
{ name: 'group', type: 'text' },
|
||||
{ name: 'sort', type: 'number' },
|
||||
],
|
||||
indexes: ['CREATE UNIQUE INDEX idx_menu_items_uid ON menu_items (uid)'],
|
||||
})
|
||||
return app.save(collection)
|
||||
},
|
||||
(app) => {
|
||||
// Revert to the original placeholder schema.
|
||||
try {
|
||||
const newCollection = app.findCollectionByNameOrId('menu_items')
|
||||
app.delete(newCollection)
|
||||
} catch (e) {
|
||||
// nothing to revert
|
||||
}
|
||||
|
||||
const collection = new Collection({
|
||||
name: 'menu_items',
|
||||
type: 'base',
|
||||
listRule: '',
|
||||
viewRule: '',
|
||||
createRule: null,
|
||||
updateRule: null,
|
||||
deleteRule: null,
|
||||
fields: [
|
||||
{ name: 'uid', type: 'text', required: true },
|
||||
{ name: 'category', type: 'text', required: true },
|
||||
{ name: 'name', type: 'text', required: true },
|
||||
{ name: 'description', type: 'text' },
|
||||
{ name: 'price', type: 'number' },
|
||||
{ name: 'pairing', type: 'text' },
|
||||
{ name: 'tag', type: 'text' },
|
||||
{ name: 'image', type: 'text' },
|
||||
{ name: 'sort', type: 'number' },
|
||||
],
|
||||
indexes: ['CREATE UNIQUE INDEX idx_menu_items_uid ON menu_items (uid)'],
|
||||
})
|
||||
return app.save(collection)
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user