Skip to content

TML-3789: PostgreSQL Json stores jsonb by default, and Json(storage: json) keeps a json column - #30966

Closed
wmadden-electric wants to merge 19 commits into
mainfrom
tml-3789-json-convenience-type
Closed

wmadden-electric wants to merge 19 commits into
mainfrom
tml-3789-json-convenience-type

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor
model Event {
  id      Int                 @id
  payload Json                // a jsonb column
  raw     Json(storage: json) // a json column
}

On PostgreSQL, Json becomes a convenience type, like Int and String in #30942. It means "a JSON value". Bare, it stores jsonb. Json(storage: json) stores plain json. Both read a JsonValue.

You write Explicit type Codec Column
Json Jsonb pg/jsonb@1 jsonb
Json(storage: json) PlainJson pg/json@1 json

PlainJson is the new name of the type that Json named until now. The naming rule would give it Json, which the convenience type now takes. No suffix for the JavaScript value separates it from jsonb, because both read the same values, so it takes a qualifier: plain json, as opposed to jsonb. ADR 316 records this as a naming rule.

This changes existing contracts

A PostgreSQL field written Json in an existing Prisma 8 schema moves from a json column to a jsonb column:

  • prisma contract emit writes a new storage hash. Nothing warns, because Json is still the right name to write. A type choice cannot carry a deprecation warning without a framework change.
  • prisma db verify reports a hash mismatch, and prisma db verify --schema-only names the column: The contract column is "jsonb" and the database column is "json".
  • prisma migration plan and prisma db update do not change the column on their own. The planner treats json to jsonb as a change that can lose data, and asks about each field. Answer --delete Event.payload to accept PostgreSQL's in-place conversion, or --convert Event.payload on migration plan to write your own. It stays a data-loss question on purpose: jsonb drops duplicate keys, normalizes whitespace and key order, and refuses the \u0000 escape that json accepts.
  • To keep a json column, write Json(storage: json) or PlainJson. The contract does not change.

Not affected:

  • Fields written Jsonb.
  • Prisma 7 schemas: Prisma 7's Json already meant jsonb, and Json @db.Json reads as PlainJson.
  • SQLite, MySQL and MongoDB.

This is the second change to Json in the release candidates. The 0.16-to-0.17 upgrade bound Json to json and told users who meant jsonb to write Jsonb. Those users are not affected now. ADR 316 records the change as an exception to ADR 257's rule that a rename keeps a deprecated alias, and says why.

The app and extension upgrade instructions are in upgrade-instructions/pending/postgres-json-convenience-type/.

The tools

  • contract infer and contract print write Json for a jsonb column and Json(storage: json) for a json column. A printed schema that showed Jsonb now shows Json.
  • In TypeScript, type.Json() is typed as Jsonb and type.Json({ storage: 'json' }) as PlainJson.
  • The column helper jsonColumn is renamed plainJsonColumn, after its explicit type. jsonbColumn keeps its name.
  • The refusal for the removed field.json() preset now says to write Json.

Repository schemas

Schemas that mirror a real json column keep it with Json(storage: json): the Supabase contract, the engines native-types port, and the collection-methods fixture. Their contract.json files are unchanged. The Prisma port fixtures that translate upstream Prisma's Json, which is jsonb, now store jsonb.

The Supabase contract was edited by hand. Its generator already does not reproduce the committed contract on main (TML-3598).

Also in this PR

Two ADRs were numbered 316 on main. This project's ADR merged first, so the search_path ADR from #30956 is renumbered 318, with its links.

Alternatives considered

  • Json defaults to json. That would avoid the contract change. It was rejected because jsonb is what users should get by default: it can be indexed and compared, and Prisma 7, Django, Ecto, MikroORM, Hibernate and Gel all default to it.
  • The name JsonText. Rejected because it reads as JSON kept in a text column, which is what SQLite's Json is.
  • pg.Json in the target's namespace. Not possible: a type choice row names a type constructor at its own level of the namespace, and changing that changes the framework.
  • A warning on bare Json for one release line. Not possible without a framework change, and it would fire on the name users should write.

Closes TML-3789.

Agent: dostoevsky-67

Summary by CodeRabbit

  • New Features
    • PostgreSQL Json now defaults to jsonb; use Json(storage: json) or PlainJson to select json.
    • Schema inference and generated output now distinguish json from jsonb.
  • Important Changes
    • Changing an existing json field to bare Json may require a migration to jsonb and explicit consent.
    • The PostgreSQL raw-JSON helper is now named plainJsonColumn.
  • Documentation
    • Added upgrade guidance for these PostgreSQL JSON changes.

…PlainJson, reviewed by an architect and a principal engineer

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…lt, and the json type is PlainJson

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…age: json) for a json column

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…lainJson, and the planner asks before turning a json column into jsonb

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nvenience type over Jsonb and PlainJson

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…rage: json), and the Prisma port fixtures store jsonb

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…keep json or move to jsonb

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…over and print as Jsonb and PlainJson

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… and moved to jsonb with migration plan --delete

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… first as the scalar convenience types ADR, and the index lists Json among them

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…umns infer writes, and leaves SQLite and MongoDB Json names to TML-3790; ADR 257 says why PlainJson is not named after its database type

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… schema copies, and detect type.Json({}) and imports from @prisma/orm-target-postgres

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…json) against a live database, and db verify reports the json to jsonb mismatch

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…y --schema-only names the Json column

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…onb or json, and an as option

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 November 6, 2026 18:57
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

PostgreSQL Json now defaults to jsonb; Json(storage: json) selects PlainJson. The change updates type construction, inference, adapters, extension contracts, migration checks, and upgrade guidance. PostgreSQL’s plain json adapter descriptor is now named plainJsonColumn.

Changes: PostgreSQL JSON type choice

Layer / File(s) Summary
Type contract and constructor
packages/3-targets/postgres/1-target/src/core/type-constructors.ts, docs/architecture docs/*, docs/reference/scalar-types.md, skills/prisma-8/references/contract.md
Json is documented and implemented as a storage-based type choice. It defaults to Jsonb; storage: json selects PlainJson. The explicit json type is renamed PlainJson.
Authoring, adapters, and type mappings
packages/2-sql-family/2-authoring/*, packages/3-targets/postgres/*, packages/3-extensions/arktype-json/README.md, packages/3-extensions/supabase/*, test/integration/test/psl-*, test/integration/test/authoring/*, test/e2e/framework/test/fixtures/contract.ts
Preset rewrites, adapter descriptors, Supabase contract fields, type inference, and related fixtures and tests use the updated JSON type names and mappings. The PostgreSQL plain-JSON descriptor is named plainJsonColumn.
Migration verification and planning
packages/3-targets/postgres/1-target/test/migrations/planner.data-loss.test.ts, test/integration/test/cli-journeys/json-convenience-type-move.e2e.test.ts
Tests cover the json to jsonb change, including verification output, consent for the planned alteration, applying the migration, and verification afterward.
Upgrade guidance and detection
upgrade-instructions/pending/postgres-json-convenience-type/*, test/integration/test/upgrade-instructions/postgres-json-convenience-type/detection.test.ts
Upgrade instructions describe how to retain json or move to jsonb, rename the helper, and update constructor lookups. Tests check the guide detection patterns.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant ContractEmitter
  participant Verifier
  participant MigrationPlanner
  participant PostgreSQL
  CLI->>ContractEmitter: Emit contract for bare Json
  ContractEmitter->>CLI: Return contract storage hash
  CLI->>Verifier: Verify contract against database
  Verifier->>PostgreSQL: Read column storage
  PostgreSQL->>Verifier: Report json storage
  Verifier->>CLI: Report contract jsonb versus database json
  CLI->>MigrationPlanner: Plan json-to-jsonb change
  MigrationPlanner->>CLI: Request data-loss consent
  CLI->>MigrationPlanner: Retry planning with consent
  MigrationPlanner->>CLI: Return jsonb column alteration
  CLI->>PostgreSQL: Apply migration
  CLI->>Verifier: Verify migrated schema
  Verifier->>PostgreSQL: Read column storage
  PostgreSQL->>Verifier: Report jsonb storage
  Verifier->>CLI: Verification succeeds
Loading

Suggested reviewers: sevinf

Merge Risk: Minimal · up to 0d791

No actionable issue remains in the supplied review evidence; the change is mergeable after normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change to PostgreSQL Json storage.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 31 files. (17 skipped: 17 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: prisma/orm
  • Branch: main
  • File: .coderabbit.yml
  • Commit: 557c0d4
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c38d266-6384-4ffc-a3b5-d9f41e5fb4b5
Commits

Reviewing files that changed from the base of the PR and between 557c0d4 and 0d791c7.

Files ignored due to path filters: 13

  • projects/scalar-convenience-types/deferred.md is excluded by !projects/**
  • projects/scalar-convenience-types/plan.md is excluded by !projects/**
  • projects/scalar-convenience-types/spec.md is excluded by !projects/**
  • test/integration/test/ports/prisma/functional/issues-21454-type-in-json/_fixture/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/issues-21454-type-in-json/_fixture/generated/contract.json is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/issues-29174-jsonb-parameter-regression/_fixture/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/issues-29174-jsonb-parameter-regression/_fixture/generated/contract.json is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/issues-29267-uint8array-in-json/_fixture/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/issues-29267-uint8array-in-json/_fixture/generated/contract.json is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/json-fields/_fixture/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/ports/prisma/functional/json-fields/_fixture/generated/contract.json is excluded by !**/generated/**
  • test/integration/test/sql-orm-client/fixtures/without-conflict-target/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/sql-orm-client/fixtures/without-conflict-target/generated/contract.json is excluded by !**/generated/**
Files selected for processing: 49

  • docs/architecture docs/ADR-INDEX.md
  • docs/architecture docs/adrs/ADR 257 - Scalar types are named after the target on every surface.md
  • docs/architecture docs/adrs/ADR 312 - A Postgres extension is a contract entity, and db sign refuses a space with unmet invariants.md
  • docs/architecture docs/adrs/ADR 316 - PostgreSQL scalars get convenience types.md
  • docs/architecture docs/adrs/ADR 318 - An extension pack's extension is found through the connection's search_path.md
  • docs/reference/scalar-types.md
  • packages/2-sql-family/2-authoring/contract-psl/README.md
  • packages/2-sql-family/2-authoring/contract-psl/src/removed-field-presets.ts
  • packages/2-sql-family/2-authoring/contract-psl/test/interpreter.removed-field-presets.test.ts
  • packages/2-sql-family/2-authoring/contract-ts/src/removed-field-presets.ts
  • packages/2-sql-family/2-authoring/contract-ts/test/removed-field-presets.test.ts
  • packages/3-extensions/arktype-json/README.md
  • packages/3-extensions/supabase/scripts/generate-contract.ts
  • packages/3-extensions/supabase/src/contract/CONTRACT-FIDELITY.md
  • packages/3-extensions/supabase/src/contract/contract.prisma
  • packages/3-targets/postgres/1-target/src/core/migrations/postgres-migration.ts
  • packages/3-targets/postgres/1-target/src/core/migrations/resolve-ddl-schema.ts
  • packages/3-targets/postgres/1-target/src/core/type-constructors.ts
  • packages/3-targets/postgres/1-target/test/migrations/planner.data-loss.test.ts
  • packages/3-targets/postgres/1-target/test/prisma7-type-map.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/infer-column-types.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/infer-parse-emit.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/inferred-psl/inferred-psl.defaults-and-types.test.ts
  • packages/3-targets/postgres/1-target/test/psl-infer/inferred-psl/inferred-psl.literal-defaults.test.ts
  • packages/3-targets/postgres/1-target/test/type-choice-inferred-marks.test.ts
  • packages/3-targets/postgres/1-target/test/type-constructors.test.ts
  • packages/3-targets/postgres/2-adapter/README.md
  • packages/3-targets/postgres/2-adapter/src/exports/column-types.ts
  • packages/3-targets/postgres/9-facade/test/contract-builder/scalar-convenience-types.test-d.ts
  • packages/3-targets/postgres/9-facade/test/scalar-convenience-type-helpers.test.ts
  • packages/3-targets/postgres/9-facade/test/scalar-type-parity.test.ts
  • skills/prisma-8/references/contract.md
  • skills/prisma-8/references/quickstart.md
  • test/e2e/framework/test/fixtures/contract.ts
  • test/integration/test/authoring/lsp-postgres-convenience-types.test.ts
  • test/integration/test/authoring/preset-replacements/preset-replacement-rows.ts
  • test/integration/test/cli-journeys/infer-roundtrip-fidelity.prisma7-defaults.e2e.test.ts
  • test/integration/test/cli-journeys/json-convenience-type-move.e2e.test.ts
  • test/integration/test/convenience-scalar-types/convenience-scalar-types.integration.test.ts
  • test/integration/test/planner-golden/fixtures/postgres/contract.ts
  • test/integration/test/ports/engines/queries/data_types/native/postgres/_fixture/other/contract.prisma
  • test/integration/test/ports/prisma/functional/legacy-json/_fixture/contract.prisma
  • test/integration/test/psl-infer/convenience-scalar-types-infer.integration.test.ts
  • test/integration/test/psl-infer/marked-types-round-trip.integration.test.ts
  • test/integration/test/psl-print/prisma7-convenience-types-print.integration.test.ts
  • test/integration/test/sql-orm-client/fixtures/collection-methods/contract.prisma
  • test/integration/test/upgrade-instructions/postgres-json-convenience-type/detection.test.ts
  • upgrade-instructions/pending/postgres-json-convenience-type/app/instructions.md
  • upgrade-instructions/pending/postgres-json-convenience-type/extension/instructions.md
Files with no reviewable changes: 1

  • test/integration/test/ports/prisma/functional/legacy-json/_fixture/contract.prisma

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma/orm-extension-arktype-json

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

@prisma/orm-extension-middleware-cache

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

@prisma/orm-extension-paradedb

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

@prisma/orm-extension-pgvector

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

@prisma/orm-extension-postgis

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

@prisma/orm-extension-supabase

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

@prisma/orm-family-mongo

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

@prisma/orm-family-sql

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

@prisma/orm-framework

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

@prisma/orm-mongo

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

@prisma/orm-mysql

npm i https://pkg.pr.new/@prisma/orm-mysql@30966

@prisma/orm-postgres

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

@prisma/orm-postgres-contrib

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

@prisma/orm-sqlite

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

@prisma/orm-target-mongo

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

@prisma/orm-target-mysql

npm i https://pkg.pr.new/@prisma/orm-target-mysql@30966

@prisma/orm-target-postgres

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

@prisma/orm-target-sqlite

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

@prisma/orm-toolchain

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

commit: 0d791c7

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 284.03 KB (+0.03% 🔺)
postgres / emit 248.21 KB (+0.03% 🔺)
mongo / no-emit 227.37 KB (0%)
mongo / emit 183.99 KB (0%)
cf-worker / no-emit 346.22 KB (+0.02% 🔺)
cf-worker / emit 306.19 KB (+0.02% 🔺)

@wmadden-electric

Copy link
Copy Markdown
Contributor Author

Closing without merging. PostgreSQL Json stays the explicit type for a json column, and Jsonb for jsonb: a name that matches one PostgreSQL type verbatim must not mean another. Users who need equality or indexes should get clearer errors pointing them to Jsonb instead. Decision: https://github.com/prisma/orm/blob/tml-3789-json-stays-explicit/projects/scalar-convenience-types/decision-json.md

@wmadden-electric

Copy link
Copy Markdown
Contributor Author

Correction to the closing note above: Json on PostgreSQL does get a convenience type. What was decided is only the default. Json keeps meaning a json column, and Json(storage: jsonb) gives a jsonb column. That is being built under TML-3789 in a new pull request; this one stays closed because it made jsonb the default.

opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-prisma__orm that referenced this pull request Nov 17, 2026
…son still gives json, and sql.String(n) is now sql.Varchar(n) (prisma#31065)

```prisma
model Event {
  id      Int    @id
  payload Json                  // a json column, as before
  search  Json(storage: jsonb)  // a jsonb column
  code    sql.Varchar(12)       // was sql.String(12)
}
```

## What changes for a user

**`Json` is a convenience type on PostgreSQL.** It has one option,
`storage`:

| Written | Explicit type | Column |
| --- | --- | --- |
| `Json` or `Json(storage: json)` | `PlainJson` | `json` |
| `Json(storage: jsonb)` | `Jsonb` | `jsonb` |

- No schema, contract or database changes. A field written `Json` keeps
its `json` column. `pnpm fixtures:check` shows no difference.
- `contract infer` and `contract print` write a `json` column as `Json`
and a `jsonb` column as `Json(storage: jsonb)`. They wrote `Jsonb`
before. `Jsonb` remains valid.
- The Prisma 7 reader writes Prisma 7's `Json`, which was `jsonb`, as
`Json(storage: jsonb)`, and `Json @db.Json` as `Json`.
- In a TypeScript contract, `type.Json()` and `type.Json({ storage:
'jsonb' })` are typed as the explicit type they choose. The column
helper `jsonColumn` is renamed `plainJsonColumn`, with no alias.
- The reference docs say what a `json` column cannot do (equality
filters, indexes, unique constraints) and that `Json(storage: jsonb)`
can. A new integration test shows the index and unique limits against
PostgreSQL.

**`sql.String(n)` is renamed `sql.Varchar(n)`** on PostgreSQL, SQLite
and MySQL. `sql.String` stays for one release line as a deprecated
alias: in PSL it warns `PSL_DEPRECATED_SCALAR_NAME` and emits the same
contract; in TypeScript it still compiles.

Both renames have upgrade instructions with detection patterns in
`upgrade-instructions/pending/postgres-json-convenience-type/`.

## Why

- **`Json` defaults to `json`.** `Json` is the exact name of a
PostgreSQL type, so it must not mean a different one. A user who wants
`jsonb` says so.
- **`PlainJson` exists because a convenience type and an explicit type
cannot share a name.** A type choice names its explicit type in the same
namespace. Users meet `PlainJson` in hover text, the type reference, and
the refusal of `@db.Json`. The tools never write it.
- **`sql.String` shared a name with the `String` convenience type and
meant something else** (a `varchar(n)` column). The namespace is now
`sql.Varchar(n)` and `sql.Char(n)`.

## ADRs

- ADR 316 gains `Json`, the rule for naming an explicit type whose
natural name is a convenience name, the reason `BigInt` is kept as its
own concept, and the `sql.Varchar` rename. ADR 257 and ADR 279 are
amended to match.
- Main had two ADRs numbered 316. The one about an extension pack's
extension and the search path is now ADR 321, in its own commit
(`f1f5d2a83b`). ADR 320 is taken by prisma#30926.

## Also in this pull request

`projects/scalar-convenience-types/spec.md` and `plan.md` hold the
design for the rest of the project: the same eight convenience types on
MongoDB, SQLite and MySQL, each in a later pull request.

## Verification

- `/drive-code-review` (system design and code passes), two rounds; the
second is clean on the pushed tip, with all acceptance criteria for this
change passing.
- Manual QA with the real CLI against a local PostgreSQL: emit,
refusals, `db init`, `contract infer`, `contract print` round-trip, `db
verify`, a TypeScript contract, and the Prisma 7 reader.
- No source file under `packages/1-framework` changes.

## Known gaps, tracked separately

- `Json @unique` or an index on a `Json` field fails only when the
migration runs, with PostgreSQL's own message, which does not mention
`Json(storage: jsonb)`. TML-3833 covers a clear error.
- The TypeScript compiler suggests `jsonbColumn` for the removed
`jsonColumn`. The upgrade instruction names the right replacement.

## Alternatives considered

- **Default `Json` to `jsonb`.** Built in prisma#30966 and closed: it changed
every existing `Json` column and made a PostgreSQL type name mean
another type.
- **No convenience type for `Json`.** Leaves no way to say "a JSON
value" and choose its storage, which every other scalar now has.
- **Name the explicit type `JsonJson`**, by the value-suffix rule. It
says nothing.
- **Rename `sql.String` inside the SQLite pull request.** PostgreSQL is
the released target it affects, so it ships here.

Closes TML-3789.

Agent: genghis-36


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* PostgreSQL `Json` now supports `json` storage by default and `jsonb`
via an explicit storage option. The explicit `json` type is named
`PlainJson`.
* Variable-length SQL text types are now named `sql.Varchar`;
`sql.String` remains available as a deprecated alias.
* The PostgreSQL untyped JSON column helper is now named
`plainJsonColumn`.

* **Documentation**
* Updated reference materials and migration guidance to explain the new
names, storage choices, and JSON limitations, including unsupported
equality filtering, indexing, and unique constraints for `json`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
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.

2 participants