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
Open
Conversation
…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 detectedLatest commit: f7e8477 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
Contributor
|
Could not push formatting changes to this fork. The contributor may have "Allow edits by maintainers" disabled. Please run the formatter locally: |
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>
Contributor
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
SchemaRegistry.updateFieldbuilt itsSETclause withouttype/column_type, andUpdateFieldInputhad notypefield, soemdash seed --on-conflict update(and the seed update branch inseed/apply.ts) couldn't express a field-type change. Re-seeding after changing a field's type inseed.jsonreported success and bumpedfields.updated, while_emdash_fields.type/column_typekept their old values — typegen then regenerated stale TS types with no warning.This adds
typetoUpdateFieldInputand writestype/column_typeinupdateField:string→slug, bothTEXT) is applied.text→portableText,TEXT→JSON) is rejected with aFIELD_TYPE_COLUMN_CHANGESchemaError, because there is no in-place column migration and silently rewriting only the metadata would desynccolumn_typefrom the realec_*column.The seed update branch now passes the field
typethrough, so a re-seed either applies the change or fails loudly instead of silently dropping it. Backwards-compatible: callers that don't passtypeget a no-op write of the existing value.Closes #1397
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (targeted:schema/registry.test.ts+seed-on-conflict+ seed/schema suites)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
New tests cover both layers:
updateFieldapplies a same-affinity change and rejects an affinity-changing one;applySeed --on-conflict updatepersists a same-affinity change and rejects an affinity-changing one instead of silently reporting success. Schema + seed suites green (248 + 85 tests).