notices: add the created/updated fields everything sorts by
The collection was declared with exactly the fields it needs -- message, active, endsAt -- and PocketBase adds no created/updated unless asked. Both readers sort by -created, so both got 400 for the life of the feature: the app's NoticeService caught it and swallowed it, and the dashboard's own listing showed 'zatím žádné' however many notices existed. Writing worked throughout; nothing could read what was written. Additive and reversible. created is onCreate only; updated moves on every save, which costs nothing and is what a pull cursor wants.
This commit is contained in:
parent
5a4112f41f
commit
ad38989f00
1 changed files with 36 additions and 0 deletions
36
pb_migrations/1793500000_notices_autodate.js
Normal file
36
pb_migrations/1793500000_notices_autodate.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
// 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);
|
||||
},
|
||||
);
|
||||
Loading…
Reference in a new issue