Improve deployed schema evolution workflow for Cloudflare D1 sites #1750
Replies: 1 comment
|
Hi I would like to request the option to use code-driven schemas which are not editable by my clients in the CMS (only in local dev). I don't personally want my collection schemas being editable in production in the first place, because you could add a new field to a collection in production, but nothing will use it until I deploy new code. For the sites I'm building, if my users do change the schema in production, the only possible change will be to break something (which is why I only give them access level: Editor, which disables other forms of access I wish they could have). That said, I do understand why others would want to use the "cms-driven" approach, so my request is to support a second mode "code-driven" collection schemas, which I would use in most cases, like this: pnpm dev # shape the collection in the admin
pnpm schema:dump --url http://127.0.0.1:4321 # + changes
git commit # the shape is now in source
pnpm schema:push --url https://production.url --dry-run # make sure it matches
pnpm schema:push --url https://production.url # apply changesI am using these scripts to apply schema changes when I deploy:
These specific scripts are a little janky to use in their nascent form, but for me, they make it feel like a I think it would be quite dreamy actually, to have a workflow where simpler changes get applied via simple schema-diff, and more complex ones get an imperative migration -- You could run a site for years and make hundreds of changes to the schema, and probably still only have a few files in your migrations folder. That would be neat 🌴🏖️🌴 |
Uh oh!
There was an error while loading. Please reload this page.
This Roadmap discussion mirrors #442: Improve deployed schema evolution workflow for Cloudflare D1 sites.
Use this discussion to upvote the roadmap item and discuss priority, use cases, and product feedback. Keep implementation tracking, reproduction details, and PR-specific feedback on the source issue.
enhancement,area/cloudflare,area/docs,roadmap/1.0,roadmap/data-safetyOriginal Issue
Summary
While adapting an EmDash Cloudflare template site away from the starter blog model, the rough edge was not deployment itself, but evolving an already-initialized remote D1 database cleanly.
Fresh setup works. Code deploys work. Content editing works.
What feels underpowered right now is the workflow for changing a deployed site's schema/content model after the first setup.
What happened
I changed an EmDash Cloudflare site from the starter blog structure to a different architecture:
The surprising parts were:
emdash schema,emdash seed,emdash doctor) appear primarily oriented around a local database path, not a deployed Cloudflare D1 target.package.json -> emdash.seedis not set (or.emdash/seed.jsonis not present), the build embeds the default seed, which can make a fresh deployed DB initialize with the wrong model.Why this matters
For real projects, there are at least four distinct workflows:
The first three are understandable.
The fourth is where the current workflow feels unclear.
Request
It would help a lot if EmDash had a more explicit story for deployed schema evolution, especially for Cloudflare D1 sites. For example, any combination of:
Concrete ask
Could EmDash expose or document a supported way to evolve a deployed Cloudflare D1-backed site's schema/content model over time, rather than treating fresh database setup as the main escape hatch?
That would make EmDash feel much more production-ready for nontrivial sites.
All reactions