Skip to content

TML-3385: Plan the data types own column types project - #30518

Closed
wmadden-electric wants to merge 17 commits into
mainfrom
data-types-completion
Closed

wmadden-electric wants to merge 17 commits into
mainfrom
data-types-completion

Conversation

@wmadden-electric

Copy link
Copy Markdown
Contributor

At a glance

Today a column's database type name lives in about eight places that can disagree. After this project, one declaration per data type holds it, and every tool reads that declaration:

export const pgTimestamptz = sqlDataType('pg/timestamptz', {
  params: temporalPrecision,                                        // precision 0 to 6
  texts: [
    { text: 'timestamptz', written: true },                         // what migrations write
    { text: 'timestamptz({precision})', written: true },
    { text: 'timestamp with time zone', catalog: true },            // what Postgres reports
    { text: 'timestamp({precision}) with time zone', catalog: true },
  ],
  casts: { [pgText.id]: unchanged },
});

A contract column then names its data type instead of storing a free string:

{ "codecId": "pg/timestamptz-temporal@1", "dataType": "pg/timestamptz", "typeParams": { "precision": 3 }, "nullable": false }

With pgvector in the stack, db verify recognises a vector(1536) column by exact equality, and contract infer prints pgvector.Vector(1536) instead of Unsupported("vector(1536)").

Linked issue

Refs TML-3385. Linear project: Data types own column types. Slice tickets, in order: TML-3386, TML-3388, TML-3387, TML-3389.

Summary

This pull request adds the plan for finishing ADR 254. It contains no code. The files are under projects/data-types-completion/:

  • spec.md: purpose, non-goals, requirements, definition of done.
  • design.md: the exact design for all four slices, written so an implementer has nothing to decide.
  • plan.md: slice order, dependencies, checks and halt conditions.
  • design-notes.md: every decision with its reason, including the ones Will made.
  • research.md and inventory/: the survey of the code the design rests on, including output from a real Postgres and SQLite.
  • reviews/design-verification.md: an independent review of the design against the code, whose findings are applied.

Decision

  1. Each data type declares its facts. A SQL data type declares the texts a migration writes, the texts the database catalog prints, its parameters with one bound each, and how its parameters are normalised. The shared code lives in packages/2-sql/1-core/contract. Targets and extensions declare types; no shared package does.
  2. Every copy is deleted. Codec targetTypes, the rendering hooks, the Postgres codec name hook, the introspection normalisers and contract infer's hand-written type tables all go.
  3. The contract stores the data type id. nativeType leaves contract.json before 8.0 ships. Every SQL hash changes once. Users run an upgrade script, then db sign on each database.
  4. SQLite's data types are what SQLite stores: text, integer, real, blob, and the two character types. JSON, datetime and 64-bit integers are codecs of those types.
  5. Verify compares exactly. Introspection resolves the reported type to a data type id and parameters through the declarations, including extension types. A type nobody claims is a mismatch, and contract infer fails on it rather than printing Unsupported(...).
  6. Function arguments are typed. The 8 in @default(nanoid(8)) is checked by the same rule as a column default, using the argument building block from TML-3367.

Slices

# Ticket What it delivers Waits for
1 TML-3386 Declarations; every copy deleted; no contract change nothing
2 TML-3388 dataType in the contract; SQLite corrected; upgrade script; db sign over every contract space slice 1
3 TML-3387 Introspection, verify and infer read the declarations slice 2, TML-3253
4 TML-3389 Function arguments, enum member values and discriminator values checked by the cast rule slice 1, TML-3367

Notes for the reviewer

  • The design review found 14 blockers and 26 gaps in the first draft, all verified against the code. The main consequences are recorded at the end of design-notes.md: the contract-format slice now comes before the verify slice, because SQLite would otherwise report drift on every column; and the upgrade script rehashes old snapshots instead of refusing them, because apps/telemetry-backend shows real projects have them.
  • One DDL change is deliberate: a column that uses a types {} alias of a type without parameters is no longer written as a quoted name. Today VarChar behind an alias writes "character varying", which Postgres rejects.
  • The retired codec ids the upgrade script maps are taken from the rc.5 to rc.6 upgrade guide.

Testing performed

None: documentation only. pnpm lint:docs passes.

Skill update

n/a: planning documents only. The slices update the codec authoring guide, the error reference and the upgrade instructions.

Checklist

  • All commits are signed off (git commit -s).
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated: n/a, documentation only.
  • The PR title is in TML-NNNN: <sentence-case title> form.
  • The Skill update section is filled in.

Alternatives considered

  • Keep nativeType in the contract as a derived field. No hash would move, but the contract would keep two sources for one fact forever. Rejected by Will: 8.0 is the last point where the format can change without a major version.
  • A map from old to new hashes that every command applies automatically. Rejected in favour of re-signing each database with db sign, an existing command.
  • SQLite data types that share a storage class (sqlite/json stored as sqlite/text). Rejected: a data type is what the database stores; the distinctions belong to codecs.
  • Printing Unsupported(...) for unknown types. Rejected: it is not a Prisma 8 type, so contract emit cannot read what infer printed.

Agent: romulus-48

wmadden-electric and others added 15 commits September 27, 2026 11:49
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…m the contract

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…d contracts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ript

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ssion settles

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…and infer failure

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ite data types

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…their decisions

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric requested a review from a team as a code owner September 29, 2026 21:29
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (9)
  • projects/data-types-completion/design-notes.md is excluded by !projects/**
  • projects/data-types-completion/design.md is excluded by !projects/**
  • projects/data-types-completion/inventory/change-list.md is excluded by !projects/**
  • projects/data-types-completion/inventory/data-types.md is excluded by !projects/**
  • projects/data-types-completion/inventory/type-constructors.md is excluded by !projects/**
  • projects/data-types-completion/inventory/upgrade-rewrite.md is excluded by !projects/**
  • projects/data-types-completion/plan.md is excluded by !projects/**
  • projects/data-types-completion/research.md is excluded by !projects/**
  • projects/data-types-completion/spec.md is excluded by !projects/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration
  • Configuration used: Repository: prisma/orm/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 100fe7b5-b7fd-4b2c-b18d-606954e0d2c6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma/orm-extension-arktype-json

npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@30518

@prisma/orm-extension-middleware-cache

npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@30518

@prisma/orm-extension-paradedb

npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@30518

@prisma/orm-extension-pgvector

npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@30518

@prisma/orm-extension-postgis

npm i https://pkg.pr.new/@prisma/orm-extension-postgis@30518

@prisma/orm-extension-supabase

npm i https://pkg.pr.new/@prisma/orm-extension-supabase@30518

@prisma/orm-family-mongo

npm i https://pkg.pr.new/@prisma/orm-family-mongo@30518

@prisma/orm-family-sql

npm i https://pkg.pr.new/@prisma/orm-family-sql@30518

@prisma/orm-framework

npm i https://pkg.pr.new/@prisma/orm-framework@30518

@prisma/orm-mongo

npm i https://pkg.pr.new/@prisma/orm-mongo@30518

@prisma/orm-postgres

npm i https://pkg.pr.new/@prisma/orm-postgres@30518

@prisma/orm-sqlite

npm i https://pkg.pr.new/@prisma/orm-sqlite@30518

@prisma/orm-target-mongo

npm i https://pkg.pr.new/@prisma/orm-target-mongo@30518

@prisma/orm-target-postgres

npm i https://pkg.pr.new/@prisma/orm-target-postgres@30518

@prisma/orm-target-sqlite

npm i https://pkg.pr.new/@prisma/orm-target-sqlite@30518

@prisma/orm-toolchain

npm i https://pkg.pr.new/@prisma/orm-toolchain@30518

commit: 1e9cc29

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 205.89 KB (0%)
postgres / emit 184.41 KB (0%)
mongo / no-emit 191.05 KB (0%)
mongo / emit 170.62 KB (0%)
cf-worker / no-emit 260.89 KB (0%)
cf-worker / emit 236.83 KB (0%)

wmadden-electric added a commit that referenced this pull request Oct 6, 2026
…on main

The slice plan says the branch targets main and carries the documents of planning pull request #30518. The copy of the pull request description is deleted, and the design documents no longer link to the gitignored design verification.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden-electric added a commit that referenced this pull request Oct 6, 2026
Each inventory header says it was made on 2026-09-29 for planning pull request #30518 and that its raw outputs were not kept, without the local paths or the commit not on main. The slice plan says the review artefacts are local. Design 3.1 names the PSL-only constructor sets and the targets' own sets, and 3.2 names the runtime adapter's create(stack).

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric

Copy link
Copy Markdown
Contributor Author

Closed in favour of #30547. Its project documents land with slice 1, in newer versions.

@wmadden-electric
wmadden-electric deleted the data-types-completion branch October 7, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant