Skip to content

fix(core): apply or reject field type changes on update instead of dropping them (#1397)#1556

Open
marcusbellamyshaw-cell wants to merge 2 commits into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/1397-updatefield-type-change
Open

fix(core): apply or reject field type changes on update instead of dropping them (#1397)#1556
marcusbellamyshaw-cell wants to merge 2 commits into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/1397-updatefield-type-change

Conversation

@marcusbellamyshaw-cell

@marcusbellamyshaw-cell marcusbellamyshaw-cell commented Jun 20, 2026

Copy link
Copy Markdown

What does this PR do?

SchemaRegistry.updateField built its SET clause without type / column_type, and UpdateFieldInput had no type field, so emdash seed --on-conflict update (and the seed update branch in seed/apply.ts) couldn't express a field-type change. Re-seeding after changing a field's type in seed.json reported success and bumped fields.updated, while _emdash_fields.type / column_type kept their old values — typegen then regenerated stale TS types with no warning.

This adds type to UpdateFieldInput and writes type / column_type in updateField:

  • A type change that keeps the same column affinity (e.g. stringslug, both TEXT) is applied.
  • A change that would alter the column type (e.g. textportableText, TEXTJSON) is rejected with a FIELD_TYPE_COLUMN_CHANGE SchemaError, because there is no in-place column migration and silently rewriting only the metadata would desync column_type from the real ec_* column.

The seed update branch now passes the field type through, so a re-seed either applies the change or fails loudly instead of silently dropping it. Backwards-compatible: callers that don't pass type get a no-op write of the existing value.

Closes #1397

Type of change

  • Bug fix

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (targeted: schema/registry.test.ts + seed-on-conflict + seed/schema suites)
  • pnpm format has been run
  • I have added/updated tests for my changes
  • User-visible strings in the admin UI are wrapped for translation (n/a — server-side English error message, stable SCREAMING_SNAKE_CASE code)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.8 ultracode

Screenshots / test output

New tests cover both layers: updateField applies a same-affinity change and rejects an affinity-changing one; applySeed --on-conflict update persists a same-affinity change and rejects an affinity-changing one instead of silently reporting success. Schema + seed suites green (248 + 85 tests).

…opping them (emdash-cms#1397)

SchemaRegistry.updateField built its SET clause without type/column_type,
and UpdateFieldInput had no `type` field, so `emdash seed --on-conflict
update` (seed/apply.ts) couldn't express a field-type change. Re-seeding
after changing a field's type reported success and bumped fields.updated
while _emdash_fields.type/column_type kept their old values — stale typegen
with no warning.

Add `type` to UpdateFieldInput and write type/column_type in updateField.
A type change that keeps the same column affinity (string -> slug, both
TEXT) is applied; one that would change the column type (text -> portableText,
TEXT -> JSON) is rejected with a FIELD_TYPE_COLUMN_CHANGE SchemaError, since
no in-place column migration exists and rewriting only the metadata would
desync column_type from the real ec_* column. The seed update branch now
passes the field type through.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f7e8477

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@emdashbot

emdashbot Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Could not push formatting changes to this fork. The contributor may have "Allow edits by maintainers" disabled.

Please run the formatter locally:

pnpm format

Collapse multi-line .innerJoin() calls onto single lines per the repo's
oxfmt config. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SchemaRegistry.updateField silently drops field type changes (type + column_type) on seed --on-conflict update

1 participant