Repository navigation
TML-3431: A Postgres full-text index can span several weighted fields, and the contract stores it as data - #30562
Conversation
…ng is kept Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ptions hold them One renderer draws the search document from the weight groups and the language. The gin index type validates the full-text options. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…t in the schema node, and prints as @@fullTextIndex Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… options from the resolved columns Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…hing the document the index renders Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…y its migration history through The add_post_title_search migration keeps its DDL. Its end contract is re-emitted from the migration's contract.prisma, the index takes its new wire name, and the orphaned end snapshot is removed. migration plan --from the previous migration produces the same operations. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…title above body, and verifies it clean Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… forms of fullTextMatches and fullTextRank Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…sion renames the index Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…pe is the default or registered as backsForeignKey Each index type registration declares backsForeignKey. Postgres declares it for btree and hash, not for gin, gist, spgist or brin; ParadeDB's bm25 does not. Foreign-key materialization and contract infer read the same rule, so a full-text, gin or partial index on a foreign key column no longer stands in for its backing index. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…n text exactly The PSL interpreter hands model-attribute lowering the build's warnings sink, as it already hands it the diagnostics sink. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… the foreign-key backing rule Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…pe is the default or registered as backsForeignKey Each index type registration declares backsForeignKey. Postgres declares it for btree and hash, not for gin, gist, spgist or brin; ParadeDB's bm25 does not. Foreign-key materialization and contract infer read the same rule, so a full-text, gin or partial index on a foreign key column no longer stands in for its backing index. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…pe without backsForeignKey is refused with a why and a fix The target and the extension packs register index types through indexTypeRegistryOf, which contract emit and the SQL family instance both call. The PSL build context carries the registry's answer to infer. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…acks a foreign key Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… coalesces every column, and its columns must be its fields The Postgres registry gains fullText, whose options are exactly the weight groups and the language; gin goes back to accepting any options. The schema node renders a fullText index as a gin index over its search document. A document of several columns wraps every column in coalesce, so it depends on the weight groups and the language only, never on a column's nullability. A fullText index whose columns are not the fields of its groups, in order, is refused when a Postgres namespace is built, at authoring and at load. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…n tests read Postgres's own definition back The demo's add_post_title_search migration keeps its DDL and takes the new index name; migration plan --from the previous migration produces the same operations. The weighted usage test compares the stored index definition with one built from the query's own document, asserts the whole lowered statement, and searches the nullable side of an outer join with the same document. The verify test asserts the missing index by path. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…t index type, coalesced documents and the db update rebuild Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (18)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe PR adds weighted, multi-column PostgreSQL full-text indexes. Contracts store their fields, weight groups, and language; PostgreSQL validates and renders index definitions. Full-text query operations accept matching grouped documents. ChangesPostgreSQL Full-Text Indexes
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant ContractBuilder
participant PostgresSchemaConversion
participant FullTextDocumentRenderer
participant QueryOperations
participant PostgreSQL
ContractBuilder->>PostgresSchemaConversion: fullText definition with weight groups and language
PostgresSchemaConversion->>FullTextDocumentRenderer: definition for index document rendering
FullTextDocumentRenderer->>PostgresSchemaConversion: rendered search document
QueryOperations->>FullTextDocumentRenderer: grouped query document and language
FullTextDocumentRenderer->>QueryOperations: rendered search document
QueryOperations->>PostgreSQL: full-text match or rank query
Merge Risk: ⚪ Minimal · up to This change adds weighted multi-column full-text indexes, with validation, rendering, and updated demo contracts and upgrade notes. I found no concrete merge-blocking problem in the supplied context. Existing indexes get new generated names, and the upgrade instructions already cover that. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change affects index definitions and upgrades. Checked SQL input controls remain intact, and no new privilege or data-access expansion was demonstrated. Upgrade compatibility and recovery behavior retain some uncertainty. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 38.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 83 functions across 65 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mongo
@prisma/orm-postgres
@prisma/orm-sqlite
@prisma/orm-target-mongo
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
size-limit report 📦
|
PostgresSchema reads full-text index definitions, and the module it reads them from imported the codecs for isFullTextIndexableCodec, which pulled the temporal codecs into every package that compiles PostgresSchema from source, such as the ORM client's tests. The textual-codec check moves to its own module. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…s types back a foreign key; put the PSL build context comment back above its code Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…t index branch Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… one constant for the weights fullTextIndexDefinitionOf refuses a unique fullText index, so a contract that holds one is refused when it is built and when it loads; the printer's own refusal for it is gone. An index type registration may name columnTraits, which the contract build checks through the contract's codec lookup; Postgres's fullText type requires textual. The check runs in the SQL family's index type validation at contract build, so the module PostgresSchema imports still does not import the codec list. FULL_TEXT_WEIGHTS lives in index-types.ts, and the options schema and the renderer both read their limit from it. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The @@fullTextIndex spec refuses an empty field list with PSL_INVALID_ATTRIBUTE_SYNTAX before the full-text rules run, so the PSL problem type now excludes no-fields as it excludes unique. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…des the function form The cast type and its reason still described options as the pack-declared object only. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The function receives the resolved columns of the expression fields, after a .column() override. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…te lowering This branch added it for the full-text map: warning, which now comes from the shared index lowering, and no model attribute reads it. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Every refusal of the helper carries helper and fields. The reference also names the renderFullTextIndexDocument refusal. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…sion type that is not an access method Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
control-instance.ts keeps this branch's index-type registry import; main dropped the sql-expression import. The PSL print build context takes main's data type lookup with extra data types and keeps this branch's index type registry. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…he weighted full-text index branch Generated contracts, the demo's add_post_title_search migration and its snapshots are regenerated with pnpm fixtures:emit. The migration keeps its DDL and the index name migration plan --from 20260917T0818_add_post_expires_at produces; the base's orphaned end snapshot is removed. The full-text test helpers pass the data type lookup PostgresControlAdapter now takes. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…xt index changes Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… and data type lookups main now requires Columns name their data type instead of a native type, the schema-node conversion and the planner take the type lookups, and the SQL renderer takes the data type lookup and capabilities. A column whose codec no pack registers is now refused by the build itself, so the column-trait test asserts that refusal for the unknown codec and keeps that column out of the other cases. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… as opaque SQL, as main's neighbouring cases do Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…and data types of the packs it is built from The sql-builder fixture has a pgvector column, and converting a contract to schema nodes now resolves every column's data type through the lookups. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e the index type check Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Main carries the final foreign-key backing design from #30561. Where this branch still had the earlier backsForeignKey design, main's version is kept. The full-text index type keeps its accessMethod and columnTraits, and the contract build builds the index type registry once with indexTypeRegistryOf and passes it to index lowering and validation. Generated contracts, the demo migration and the planner golden manifest are taken from main here and regenerated in a following commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The demo contract, the self-relations fixture and the demo migration that adds the post title search are emitted again: their full-text indexes are stored as the fullText type, so the index names change while the DDL body stays the same. The demo migration is rewritten in place to the new index name, and the planner golden manifest records the new names and the weighted full-text fixture table. Planner calls in the full-text planning tests pass the origin and statements main now requires, and the full-text DDL helper reads the data type lookup from the stack's dataTypes. New tests: a relation whose column a full-text index covers still gets its own backing index, which the foreign key names, and the planner equality the duplicate-index pass uses tells full-text indexes apart by weight groups, language and access method. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
A full-text index stores the columns its weight groups cover, but in the database it is a gin index over a search document rendered from those groups, so it cannot serve the equality lookups a foreign key needs. The contract build now refuses a relation's index: "<name>" that names an index of a type whose access method differs from its type literal, with CONTRACT.ARGUMENT_INVALID reported at the relation in PSL. An index of an access method, such as gin or hash, stays the relation's own claim. The Postgres target's check of a loaded contract refuses a foreign key whose stored index names a fullText index. The column-trait check of index types takes its codec lookup as a required argument and drops the message for an unknown codec, which the build refuses earlier. A full-text index and a hand-written gin index that render the same SQL are both kept and both planned; a test now pins that. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…d options compare as JSON Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The SQL builder's table proxy gains `indexes`, beside `columns`: each of the table's indexes under the name the contract source gave it (the `name:` prefix or the `map:` name), as an IndexReference holding its columns bound to the proxy's alias, its type and its options, typed from the contract. A name more than one index shares is refused with ORM.ARGUMENT_INVALID when it is read. fullTextMatches and fullTextRank take as their document a full-text index from `indexes`, one column, or a document from the new `fullTextDocument` helper in the target's full-text entry. Given an index, they search its weight groups in its language, so the query matches the index; a language option with an index, an index of another type, and weight groups passed as a bare nested array are type errors and RUNTIME.ARGUMENT_INVALID at runtime. The bare nested-array form, new in this branch, is removed. The weighted full-text integration test, the demo's SQL builder search and the docs use the index form; the integration test also searches an aliased self-join and keeps one fullTextDocument case. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
An index read from a table proxy carries columns bound to that proxy's alias, so it can name an alias the query never selects from or joins, and Postgres would then fail with a missing FROM-clause entry. Building a plan now walks the statement: each select may read the aliases of its own sources and of the queries around it, so correlated subqueries still work, and an update or delete may read its table. Any other column throws ORM.ARGUMENT_INVALID naming the alias and the sources. A name that more than one index of a table shares is left out of the `indexes` type, matching the runtime refusal, and each table proxy builds its index references once. The README says unnamed and derived indexes appear under their default prefixes, and the playground type test reads an aliased table's index only in a query on that alias. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
At a glance
A schema author indexes a post's title and body for search, with the title counting more:
Each top-level item of the list is a weight group, strongest first. Here
titleandsubtitleshare weightA, andbodygets weightB. A query names the index, andfullTextMatchesandfullTextRankread its weight groups and language from the contract:The index and the query search the same search document, one
tsvectorbuilt from the fields, so Postgres uses the index:Before this change,
@@fullTextIndextook one field, and a search over several fields had to be written by hand in every query.The problem
Postgres uses an expression index only when the query contains the same expression. Searching several fields means one search document built from all of them, with a weight per group. If a query lists the fields in another order, or uses another language or weight, Postgres scans the whole table and reports no error. And the contract stored a full-text index as an opaque SQL string, so nothing could build the query from it.
The decision
A full-text index is data in the contract: an index of type
fullText, which the Postgres target registers in its index type registry.{ "columns": ["title", "subtitle", "body"], "name": "post_search_2f1bb221", "options": { "language": "english", "weightGroups": [["title", "subtitle"], ["body"]] }, "prefix": "post_search", "type": "fullText", "unique": false }optionsis the index's definition:weightGroups, the weight groups as storage column names, andlanguage. The options schema rejects any other key. No SQL string is stored.columnslists the covered columns in order. It must equalweightGroupsread flat.fullTextdeclaresaccessMethod: 'gin'. In the database the index is aginindex over the search document. It never stands in for a foreign key's backing index: a relation on a covered column still gets its own backing index, because the contract build's duplicate-index pass (ADR 161) treats afullTextindex as different from a plain one. A relation cannot name one withindex: "<name>"either: the build refuses it, because its columns are not the index's key.The rules of a full-text index are stated once, in
fullTextIndexProblems: one to four weight groups, none empty, each column once, text columns only, and not unique.fullTextIndexProblemsis called by the options schema,@@fullTextIndex, the TypeScriptfullTextIndexhelper, the query operations, andassertFullTextIndexes, the target's check of a contract. The target runs that check when a contract is built and whencontract.jsonis loaded. At load it also checks the text rule against the target's codecs, and refuses a codec the target does not know.One renderer produces the search document from
{ weightGroups, language }. It serves the index DDL, the schema node (the target's model of the database, which the migration planner anddb verifycompare), andfullTextMatchesandfullTextRank. With more than one group, each field gets its group's weight,Afor the first; a single group gets no weight. With more than one column, every column is wrapped incoalesce, so making a column optional or required does not change the index. One column alone rendersto_tsvector('english', "title"), the expression the column operations already use.renderFullTextIndexDocument, which the target exports for extension packs, refuses weight groups that break the rules, such as an empty group.Both authoring surfaces take weight groups.
@@fullTextIndexin PSL and thefullTextIndexhelper in TypeScript (from@prisma/orm-postgres/contract-builder) take one field, or a list whose items are fields or lists of fields. Both take an optionallanguage, an optionalwhere:, andname:ormap:. Both resolve fields to storage columns, so@mapis honoured. Withmap:, both warn withPN_EXACT_NAME_BODY_COMPARISON, becausedb verifycompares the rendered document with the text Postgres prints back, character for character.A query names the index it searches. The SQL builder's table proxy has
indexes, besidecolumns: one reference per index, keyed by the name the author wrote (thename:prefix or themap:name), carrying the index's columns bound to the table's alias, its type and its options, all typed from the contract.fns.fullTextMatchesandfns.fullTextRankaccept afullTextindex reference and take the weight groups and language from it, so the query renders exactly the expression the index covers and cannot drift from it. Giving alanguagewith an index, or naming an index of another type, is a compile error and a runtimeRUNTIME.ARGUMENT_INVALID. A key two indexes share is absent from the type. A column from a table that is not one of the query's sources is refused withORM.ARGUMENT_INVALIDwhen the query is built, not left to Postgres.A document written by hand looks different. To search without an index,
fullTextDocument([[f.title, f.subtitle], [f.body]])from@prisma/orm-postgres/target/full-textbuilds a document, checked by the same rules as an index; such a query uses an index only if one covers the same document. A single column,fns.fullTextMatches(f.text, q), works as before.fullTextHeadlineis unchanged.The index type registry gets two optional fields, in
packages/2-sql/1-core/contract/src/index-types.ts. Existing registrations set neither and are unchanged.accessMethodis the access method an index of the type is created with. It defaults to the type literal.accessMethodOf(entry)reads it, andrendersIndexBody(entry)is true when it differs from the literal. Only the target can turn a type like that into an index of its access method, so when the registry is assembled, an extension pack's entry whoseaccessMethoddiffers from its type literal is refused withCONTRACT.PACK_CONTRIBUTION_INVALID.columnTraitslists the codec traits every covered column must have.fullTextdeclares['textual']. The contract build checks it against the contract's codec lookup. It refuses an index over a column that lacks a trait with the new codeCONTRACT.INDEX_INVALID. A column whose codec the lookup does not know is refused earlier in the build, withCONTRACT.CODEC_DESCRIPTOR_MISSING. This is how the text rule is checked for an index written through the general index API.This is the storage part of ADR 260 (proposed in #30428), which builds typed search scopes on top of it.
Upgrading
A full-text index declared before this change is stored in a new form, so its storage hash and its generated name change. The schema source does not change. For
@@fullTextIndex([title], name: "post_title_search")the name changes frompost_title_search_724b05e5topost_title_search_e0dd1131. The first migration after upgrading changes the index:prisma migration planfrom the previous contract renames it. A rename is instant. Use this for any large index.prisma db updatecannot tell that the old index is the new one under another name, so it drops the index and builds it again. Renaming the index by hand first avoids the rebuild.db verifyreports the new name as missing until the rename runs.An index declared with
map:keeps its exact name, so only the storage hash changes.PSL_FULL_TEXT_INDEX_ONE_FIELDis gone. The new PSL diagnostics arePSL_FULL_TEXT_INDEX_TOO_MANY_GROUPS,PSL_FULL_TEXT_INDEX_EMPTY_GROUPandPSL_FULL_TEXT_INDEX_DUPLICATE_FIELD.For extension authors:
renderFullTextIndexExpression(language, column)in@internal/target-postgres/sql-utilsis nowrenderFullTextIndexDocument({ weightGroups, language }).isFullTextIndexableCodecis removed; usefullTextIndexProblemsorpostgresCodecTraitsOffrom the new entry@internal/target-postgres/full-text-index-authoring. An index option whose value is an array or an object now enters the name hash as JSON with sorted keys, so a wire-named index with such an option gets a new name.Upgrade instructions for applications and for extensions are under
upgrade-instructions/pending/full-text-index-weight-groups/.examples/prisma-8-demoregenerates its migration20260922T1218_add_post_title_search, which now creates the index under its new name.What reviewers should look at
New files in
packages/3-targets/3-targets/postgres/src/:core/full-text-index-definition.ts: the type literal, the options schema, the registry entry,fullTextIndexProblems, the readerfullTextIndexDefinitionOf, andassertFullTextIndexes.core/full-text-search-document.ts: the renderer. Every producer of the search document callsrenderFullTextDocument.core/full-text-weight-groups.ts: the weightsAtoD, and how an author's list becomes weight groups.core/postgres-codec-traits.ts:postgresCodecTraitsOf, the traits of the target's codecs, for the text rule.exports/full-text-index-authoring.ts: a new export entry for authoring code. ThefullTextIndexhelper inpackages/3-extensions/postgresimports from it. The public packages@prisma/orm-postgresand@prisma/orm-target-postgresexpose it as./target/full-text-index-authoring.Tests:
test/integration/test/sql-builder/weighted-full-text-index-usage.test.ts(new): the DDL, the schema node and the query carry the same document text. Postgres prints the index and an index built from the query's document identically.EXPLAINwith sequential scans off uses the index, and does not when the grouping, the order or the language differ. A title match ranks above a body match.test/integration/test/family.schema-verify.full-text-index.integration.test.ts(new): a weighted index verifies clean against what Postgres returns. Amap:index is reported as changed.packages/3-targets/3-targets/postgres/test/migrations/full-text-index-planning.test.ts: a change of grouping, field order or language drops and recreates the index. A change of name prefix alone renames it. An index from before this change is renamed. A nullability change plans only the column change.packages/3-targets/3-targets/postgres/test/full-text-index-contract-load.test.ts(new): loading refuses mismatched columns, a unique index, invalid options and a column that is not text.Changes outside the Postgres target
packages/2-sql/1-core/contract:accessMethodandcolumnTraitsonIndexTypeEntry, and the refusal of an extension pack's type whose access method is not its literal, as above.indexTypeRegistryOf(target, extensions)takes the target and the extension packs separately, so it can tell them apart; the contract build and the SQL family instance pass the target on its own.validateIndexTypestakes an optional codec traits lookup.lowerAuthoredIndextakes the registry and warns formap:on a type whose body is rendered, so both authoring surfaces warn from one place.packages/2-sql/2-authoring/contract-ts: an index'soptionsmay be a function of the resolved storage columns (IndexOptionsInput,DeferredIndexOptions). Options that name columns can only be written at lowering, because a.column()override or a naming convention decides the column names. ThefullTextIndexhelper uses it.packages/2-sql/1-core/schema-ir:normalizeIndexOptionValuewrites an array or object option value as JSON, with object keys sorted at every depth. Before,[["a","b"]]and[["a"],["b"]]hashed to the same name. No existing index option is an array or an object, so no other index is renamed.Not in this pull request
wherecallback has nofns, and an operation's first argument is always the field. Weighted search from the ORM is slice 4's query fragments, which can reuse the index reference.contract inferkeeps a weighted index from a live database as an expression index,@@index(expression: ..., type: "gin"). It does not recover@@fullTextIndex.Alternatives considered
ginindex whose options hold the fields and language. Every reader would have to recognise a full-text index byginplus an option, andoptionswould hold something that is not a storage parameter. A registered type states the concept.expressionstring and parse it back. Parsing SQL to recover fields and weights is fragile, and the contract would still store a string, not the definition.fields. Everywhere elsefieldsmeans model fields, but these are storage column names. A reader would map them through the model and get the wrong column for a field with@map.weightGroupssays what the value holds.coalesce. That makes nullability part of the expression without being part of the index's name, so a nullability change silently stops the index being used.resolveOptionskey besideoptions. An index could then carry both, and lowering would silently ignore one. A function in place of the value follows the existing deferred formexpression: { fields, render }.fullTextneeds it, and its other rules are about its options. One function beside the entry states all of them.USING, and only the target converts such a type into an index of its access method, so Postgres would fail the migration with an unknown access method.Housekeeping
fullTextIndexhelper warns onmap:. Builds on TML-3430: A foreign key names its backing index, and the contract build removes duplicate indexes #30561 (TML-3430), now merged: index types declare nothing about foreign keys.contract-tsREADME and the error reference describe weight groups and the new refusals.skills/prisma-8/references/contract.mdandqueries-postgres.mddescribe weight groups, thefullTexttype, themap:warning and thefnsforms.pnpm typecheckacross the repository (171 of 171 tasks); the tests of every touched package;pnpm fixtures:check; the demo'semit:check; the integration filesfamily.schema-verify.full-text-index,psl-print/authored-contract-roundtrip,psl-print/every-postgres-contract-roundtrip,sql-builder/full-text-index-usage,sql-builder/weighted-full-text-index-usage,sql-builder/extension-functionsandsql-orm-client/extension-operations;lint:deps,lint:throws,lint:casts,lint:agent,lint:skills,lint:framework-vocabularyandcheck:upgrade-coverage. Inexamples/prisma-8-demo:migration-replay, which applies every migration, including the one that creates the full-text index, to a fresh database and verifies it against the contract;migration-integrity; and the full-text search tests.git commit -s) per the DCO.TML-NNNN: <sentence-case title>form.Agent: shonagon-99, voldemort-62
Summary by CodeRabbit