/// // Give `notices` the `created` field everything already sorts by. // // The collection was declared with exactly the fields it needs -- message, // active, endsAt -- and PocketBase does not add `created`/`updated` unless they // are asked for. Both readers ask for `sort=-created`: // // - the app's NoticeService, which caught the resulting 400 and swallowed it, // so a notice never appeared and nothing said why; // - the status dashboard's own listing, which therefore always showed "zatím // žádné" no matter how many notices existed. // // So the feature had never once worked end to end, and the failure was // invisible from both ends. Writing worked; nothing could read what was written. // // `onCreate` only for `created`; `updated` moves on every save, which is what a // pull cursor wants and costs nothing here. migrate( (app) => { const c = app.findCollectionByNameOrId("notices"); c.fields.add( new Field({ type: "autodate", name: "created", onCreate: true, onUpdate: false }), ); c.fields.add( new Field({ type: "autodate", name: "updated", onCreate: true, onUpdate: true }), ); app.save(c); }, (app) => { const c = app.findCollectionByNameOrId("notices"); c.fields.removeByName("created"); c.fields.removeByName("updated"); app.save(c); }, );