Upgrade / Upgrade to 0.10
Upgrade / upgrade-0-10
Upgrade to 0.10
The schema is version 4, deleting means the trash, schedules need a cron call, and four screens have new parts.
On this page
0.10.0 is the first npm release after 0.7.0 and contains 0.8.0 and 0.9.0. Coming from 0.7.0, do Upgrade to 0.8 first. 0.9.0 needs nothing.
1. Schema version 4#
npx @mainsoft/agent-cms migrate check
npx @mainsoft/agent-cms migrate apply # or `migrate print` and run the SQL yourselfThe step only adds things and is safe to run twice:
- columns on
cms_documents(deleted_at,deleted_by,schedule,due_at,review), oncms_versions(label,pinned,approved_by,approved_at) and oncms_assets(deleted_at,deleted_by) - the tables
cms_comments,cms_releases,cms_saved_filtersandcms_presence
Re-export cmsComments, cmsReleases, cmsSavedFilters and cmsPresence from your Drizzle schema next to the other tables.
2. Deleting now means the trash#
cms.remove, DELETE /collections/:c/:slug, the delete_document tool and deleting a file used to be final. They now put the document or file in the trash for 30 days.
- A trashed document is not found by
get,list, search or agents. Its address stays taken: creating a document with the same slug fails withslug_in_trashuntil it is restored or purged. - A trashed file's object stays in the bucket until it is purged, so a public address keeps answering until then.
createCms({ trash: { days: 0 } })keeps the old behaviour. Tests that count rows after a delete want this, orcms.trash.purge(admin, "all").- Old trash is emptied when
cms.runScheduled()runs (next section).
3. A cron call for schedules and the trash#
Scheduled publishing and emptying the trash happen when cms.runScheduled() runs. Set createCms({ cronSecret }) and call the route every few minutes:
POST /api/cms/_cron
Authorization: Bearer <cronSecret>GET works too. Without cronSecret the route answers 404. On Vercel, a cron job with CRON_SECRET sends exactly this header. Calling it from two places at once is safe.
note
Nothing publishes on its own. If no one calls the route, a scheduled document stays "Scheduled" after its time has passed.
4. Admin screens#
npx @mainsoft/agent-cms add --update
npx @mainsoft/agent-cms add cms-trash cms-releasescms-doc-editorhas two more files,cms-flow.tsxandcms-paste.ts.cms-doc-listneeds the shadcnlabelpart;cms-versionsneedsdialogandinput.cms-shelllinks to "Releases" and "Trash" for people who can edit. The target thathrefForreceives has two new kinds,releasesandtrash: add the two routes in your app.cms-preview-commentsis optional: the comment box for guests on your public preview page, for links made with "Allow comments".
5. Review is opt-in#
Nothing changes until a collection asks for it:
defineCollection({ slug: "guide", review: { agents: "required" } });From then on an API key, or an agent acting for a person, cannot publish a version nobody approved (review_required). everyone: "required" also stops people from approving their own request.
6. Type changes#
CmsDoc has deletedAt, deletedBy, schedule, dueAt, review. CmsVersion has label, pinned, approvedBy, approvedAt. DocSummary has schedule and review; DocCounts has scheduled and review. CmsAsset has deletedAt, deletedBy.
A custom CmsRepo has new methods (updateVersion, comments, releases, filters, presence), and findDoc, findDocById and findAsset take { trashed }. MemoryRepo and DrizzleRepo implement them.