feat(migrate): expression/functional indexes (identity.secondary @expr + @using)#45
Merged
Conversation
…+ @using) Adds support for functional/expression indexes — e.g. `lower(email)` (btree) and `string_to_array(tags, ',')` (GIN) — which previously could not be modeled and were silently skipped on introspect. - identity.secondary gains two db-provider attrs: - @expr — raw key EXPRESSION; used instead of @fields (which then anchors the underlying column(s) for the loader's required @fields) - @using — access method (gin/gist/hash/…); default btree (not rendered) - IndexDescriptor: expr?, using? - buildExpectedSchema: reads @expr/@using - emit (postgres): renders `USING <method> (<expr>)` - introspect (postgres): captures the access method + lifts the key expression from pg_get_indexdef (expression-key indexes are no longer skipped) - diff/indexEquals: compares using + normalized expr - registered across all ports (TS/Python/Java+Kotlin/C#); spec + embedded def updated; registry-conformance manifest, coverage snapshot, and metamodel docs regenerated - test: expression-index round-trip (expected-schema + emit) for btree functional + GIN expression indexes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
Adds functional/expression index support to the schema toolchain. Previously, expression-key indexes (e.g.
CREATE INDEX … ON t (lower(email)), or a GIN index overstring_to_array(...)) could not be modeled and were silently skipped by introspect — so a reverse-engineered/regenerated schema lost them.Model
identity.secondarygains two RDB-physical db-provider attrs:@expr— the raw key expression (e.g.lower((email)::text)). Used instead of the column list.@fieldsstill anchors the underlying column(s) (satisfies the required-@fieldsrule); the expression is the actual key.@using— access method (gin/gist/hash/…); defaultbtree, not rendered.Engine
IndexDescriptor:expr?,using?buildExpectedSchema: reads@expr/@using(expr ⇒columns: [])CREATE [UNIQUE] INDEX … ON … [USING <method>] (<expr-or-cols>) [WHERE …]pg_am.amname+ lifts the key expression frompg_get_indexdef— expression-key indexes are no longer skippeddiff/indexEquals: comparesusing+ normalizedexprCross-port + fixtures
Registered the two attrs in all ports (TypeScript, Python, Java/Kotlin, C#); updated
spec/metamodel/db.json+ the embedded def; regenerated the registry-conformance manifest, the coverage snapshot, and the metamodel docs.Tests
expression-index.test.ts— round-trips a btree functional index (lower(email)) and a GIN expression index throughbuildExpectedSchema+ emit. Fullmigrate-ts+metadatasuites green (2534 tests).🤖 Generated with Claude Code