Repository navigation
fix(migrate-ts): store long index names as Postgres keeps them in every port - #581
Merged
Merged
Conversation
…t generate refuses - migrate.foreignKeyIndexes: a <table>_<columns>_idx name over 63 bytes is cut to the 63 bytes Postgres stores (SQLite and D1 keep it whole), in migrate-ts, the C# EF context and the Kotlin Exposed tables, so a converged schema proposes nothing. The diff also keys a Postgres foreign key by its stored name, so a long <table>_<column>_fk is not proposed as a rename every run. - New shared corpus fixtures/foreign-key-index-conformance/, passed by the TypeScript, C# and Kotlin rules; two Postgres migration scenarios with a long table and column name. - mvn metaobjects:verify runs the generate goal's model refusals (output package clash, collection-name clash), with a test; Kotlin gets its own collection-name clash test. - docs/CONFORMANCE.md: the clash is per-port unit tests, not the segments corpus; the Drizzle identity start is string-tested only. - ADR-0060 records verify.handEdits as Node-CLI only by design. - The migration docs say what the code does with view grants (#574).
…e a minor on the previous one being merged Forward-ports #578 from release/1.2: release.mjs and finish-release.mjs accept a maintenance branch for a patch on its own line, refuse a version that would move npm's latest backwards, and RELEASING documents the path. A minor or major cut is now refused while the previous release/<M>.<m> holds a commit that is not on main, and RELEASING Step 0 carries the same check.
# Conflicts: # CHANGELOG.md # docs/CONFORMANCE.md
… rules; site gate timeout; ts-poet names - docs/features/api-contract.md owns api.pagination, api.unknownFields and the validation issue list; language-differences, the five port pages and the CHANGELOG point to it instead of restating them. - The site-payload gate runs its tests with a 60 s per-test timeout, so a busy machine does not read as a red release gate. - CHANGELOG names def, literalOf, arrayOf, asOneline and Import.fromMaybeString among the ts-poet names the vendored printer does not carry. - site-payload.json counts the new shared foreign-key-index corpus.
…stores it meta migrate creates and compares a declared index.lookup / identity.secondary name over 63 bytes under the name Postgres stores (its first 63 bytes). The Drizzle tables, the EF Core context and the Exposed tables now declare that cut name on Postgres (SQLite and D1 keep the whole name; MySQL is exempt), so the mapping names the index the database holds. The names artifacts keep the declared, dialect-neutral name. The shared corpus fixtures/foreign-key-index-conformance/ gains a long index.lookup and identity.secondary and declared.<dialect>.json, written by migrate-ts and read by the TypeScript, C# and Kotlin generator tests. C# ForeignKeyIndexes joins the eject engine surface, as the schema contract CheckConstraints already is.
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 Changed
migrate-tsnow cuts index names over Postgres's 63-byte limit to the stored name, for declaredindex.lookup/identity.secondarynames,@uniquenames and derived foreign-key indexes (<table>_<columns>_idx). The diff matches foreign keys by the stored name, so a converged schema proposes nothing on the next run. SQLite and D1 keep the whole name; MySQL is unchanged. Generated Drizzle, EF Core and Exposed mappings declare the same cut name on Postgres, while the names artifacts keep the declared name. The sharedfixtures/foreign-key-index-conformance/corpus gates the foreign-key rule and thedeclared.<dialect>.jsonnames for TypeScript, C# and Kotlin.verifygoal now runs the same model collision refusals asgenerate(refuseModelCollisions), so a model thatgeneraterefuses no longer verifies clean. ADR-0060 recordsverify.handEditsas a Node CLI setting by design, since only TypeScript merges hand edits forward.release/<major>.<minor>maintenance-branch rule for patch releases (scripts/lib/release-branch.mjs, used byrelease.mjsandfinish-release.mjs). CHANGELOG,docs/CONFORMANCE.md, the port pages and the migrations page are corrected to match the code.Also in this PR
release/1.2) tomain:scripts/release.mjsandscripts/finish-release.mjsaccept arelease/<major>.<minor>maintenance branch and refuse a version older than the newest release, with itsdocs/RELEASING.mdsection and tests.docs/RELEASING.mdalso gains a checklist gate: before a minor is cut frommain, every commit on the previousrelease/<major>.<minor>branch must be an ancestor ofmain.scripts/ci-local.sh) runsbun testwith--timeout 60000, so the site payload test no longer times out under load.Issues
Closes #545
Closes #548
Refs #574: the migrations page now states what the code does. When
meta migratedrops and recreates a Postgres view, it grants the view's existing privileges again; those are the onlyGRANTstatements it writes, and it declares no privileges of its own. This PR does not close #574.The raw evidence logs from validation are left out of this body; the scenario table below summarises them. Validation took two no-mistakes runs: the second added the generator-side cut of long declared index names.
Validation
Risk Assessment
✅ Low: The declared-index-name cut is applied consistently in migrate-ts, the Drizzle template, the C# EF context and the Kotlin Exposed generator, and a shared corpus with per-port runners pins it. I found no concrete failing input.
Testing
I ran the real
metaCLI against a disposable Postgres 16 container with a model declaring a 74-byteindex.lookupand a 78-byteidentity.secondary.meta migrate --applycreated both indexes under 63-byte names, andmeta verify --dbthen showed no schema drift. The Drizzle tables generated for the same model declared exactly those 63-byte names on Postgres and the whole names on SQLite. The C# and Kotlin corpus tests, the Java verify-mojo refusal test, the full migrate-ts and codegen-ts bun suites (5074 pass, 0 fail) andscripts/ci-local.sh --only gates --only java-fast --only csharpall passed. The C# integration-test lane was cut off by my 560 s timeout (exit 124) and did not finish, so its result is unknown. The configured baseline (ts-fast,ts-unit) had already passed. The container, scratch project and temp files are removed, and the worktree is clean.meta migrate --applyof a 74-byte index.lookup and 78-byte identity.secondary creates them at 63 bytes, andmeta verify --dbreports no driftmeta verify --dbreturned schemaDrift changes=[] findings=[]Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
meta migrate --applyof a 74-byte index.lookup and 78-byte identity.secondary creates them at 63 bytes, andmeta verify --dbreports no driftmeta verify --dbreturned schemaDrift changes=[] findings=[]scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchainsmeta migrate --db <postgres> --slug init --applyon a model with 74-byte index.lookup and 78-byte identity.secondary names;psql pg_indexesshowed both at 63 bytesmeta verify --db <postgres>on the same database: schemaDrift changes=[] and findings=[]Drizzle entityFile generated for the same model, postgres and sqlite dialects, compared with the live index namesbun testmigrate-ts foreign-key-index-conformance, long-declared-index-name and codegen-ts declared-index-name-cut (12 pass)dotnet test MetaObjects.Codegen.Tests --filter ForeignKeyIndex|EjectedGeneratorsAlone(71 pass)mvn -o -pl codegen-kotlin -am test -Dtest=KotlinForeignKeyIndexConformanceTest,KotlinRouteNamingTest(9 pass)mvn -o -pl maven-plugin -am test -Dtest=MetaDataVerifyModelRefusalTest(2 pass)bun test packages/migrate-ts packages/codegen-tsin server/typescript (5074 pass, 0 fail)scripts/ci-local.sh --only gates --only java-fast --only csharp --strict-toolchains: gates, csharp, java and kotlin conformance green; cut off in the csharp integration lane by my timeout, no failure recordedbaseline already run:scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.