# Slice 1: Prisma 7 contract source for Postgres _Parent project: `projects/prisma7-contract-source/`. Linear: to be created. Outcome: a Postgres user points `prisma.config.ts` at their Prisma 7 `schema.prisma` and `contract emit`, `db sign`, and `db verify` succeed against the database Prisma 7 built._ ## At a glance ```ts // prisma.config.ts import { definePrismaConfig } from 'prisma/config'; import { defineConfig as ormConfig, prisma7Schema } from '@prisma/orm-postgres/config'; export default definePrismaConfig({ orm: ormConfig({ contract: prisma7Schema('prisma/schema.prisma'), db: { connection: process.env['DATABASE_URL']! }, }), }); ``` ```bash prisma contract emit # reads schema.prisma, writes contract.json + contract.d.ts prisma db sign # verifies against the Prisma 7 database, records the marker ``` ## Chosen design - **Parser additions** in `@internal/psl-parser`: attributes on enum members (`USER @map("user")`), and field lines inside a `view` block parsed as a model-shaped block so the interpreter can reject views with a span. Both are grammar-only; nothing else in the parser changes. - **Package** `packages/2-sql/2-authoring/contract-prisma7` (`@internal/sql-contract-prisma7`), shaped like `contract-psl`: `prisma7Contract(path, { binding })` returns a `ContractConfig` whose `source.load` reads the file or directory, parses each file with `parse()`, runs the Prisma 7 interpreter, and returns `ok(contract)` or `notOk({ summary, diagnostics })`. Everything target-specific reaches it through the binding. - **Config**: `defineConfig` in `packages/3-extensions/postgres/src/config/define-config.ts` accepts `contract: string | ContractConfig`. `prisma7Schema(path)` wraps `prisma7Contract` with the Postgres binding and is re-exported from `@prisma/orm-postgres/config`. - **Relation pairing** reuses `indexFkRelations` and `applyBackrelationCandidates` from `contract-psl/src/psl-relation-resolution.ts`. The candidate type still carries a `FieldSymbol`; the planned replacement with a structural `{ name, optional, span }` was not made, so the Prisma 7 source builds the symbols the helper expects. - **Provider check**: the `datasource` block's `provider` must be `postgresql` (or `postgres`); anything else is `PSL.PRISMA7_PROVIDER_MISMATCH`. `relationMode = "prisma"` is `PSL.PRISMA7_RELATION_MODE_UNSUPPORTED`, and so is the older `referentialIntegrity = "prisma"`, which Prisma 7.10.0 still accepts with a deprecation warning and treats the same way: it creates no foreign keys (fixture `referential-integrity`). ## Rule table ### Blocks | Prisma 7 | Rule | |---|---| | `datasource` | Provider check above. `url` and everything else ignored. | | `generator` | Ignored. | | `model` | Model. Model key is the Prisma 7 model name verbatim. | | `enum` | Postgres native enum type. Type name is the enum's `@@map` or its name verbatim. Members in declared order; each member's storage value is its `@map` or its name. Fields typed by the enum use the native enum codec. | | `view` | `PSL.PRISMA7_VIEW_UNSUPPORTED`. | | `@@schema("s")` | The model's namespace is `s`. Without multiSchema, every model is in `public`. | | `@@ignore` | The model's table is kept as storage with no model ([ADR 267](https://github.com/prisma/orm/pull/30641)): its columns, primary key, uniques, indexes and foreign keys, with foreign keys to it reaching the table by name. The model and every relation to it stay out of the domain. Relation fields on other models that point at it (Prisma 7 requires them to be `@ignore`) keep their foreign keys. Strict `db verify` reports nothing for it. | ### Naming Table name is `@@map` or the model name verbatim. Column name is `@map` or the field name verbatim. The interpreter sets storage names directly, so Prisma 8's lower-first derivation never runs. ### Field types Plain scalars map to Prisma 7's Postgres storage: `String` text, `Boolean` bool, `Int` int4, `BigInt` int8, `Float` float8, `Decimal` numeric(65,30), `DateTime` timestamp(3), `Json` jsonb, `Bytes` bytea. `@db.X(args)` overrides with the Prisma 7 native type table (verification item 6; a test pins every row). A `@db.*` type written without arguments gets the column Prisma 7 creates for it: `@db.Char` is `CHAR`, which Postgres stores as `character(1)`, so it lowers to length 1; `VarChar`, `Decimal`, `Timestamp`, `Timestamptz`, `Time`, and `Timetz` take no type parameters (fixture `native-types-without-arguments`, checked by hand against Prisma 7.10.0's SQL with `db verify`). Lists are array types and their columns are nullable, because Prisma 7 emits `Type[]` columns without `NOT NULL` (see `reference/migration.sql`). `Unsupported("...")` is `PSL.PRISMA7_UNSUPPORTED_TYPE`. Native types with no Prisma 8 codec (`Money`, `Bit`, `VarBit`, `Xml`, `Oid`, `Citext`, and any other unmapped type) are `PSL.PRISMA7_NATIVE_TYPE_UNSUPPORTED`. ### Defaults | Prisma 7 | Rule | |---|---| | `autoincrement()` | Column default matching Prisma 7's sequence default (verification item 1). | | `now()` | Column default (verification item 2). | | literal, list literal, enum member | Column default. A number literal is carried as the value the column codec reads: the number when the codec reads a JSON number, otherwise what the codec decodes from the literal exactly as written. `Decimal` and `BigInt` defaults therefore keep every digit and trailing zero, as decimal text (`12345678901234567890.123456789`, `0.000000000000000001`, `-1.5`, `42`, `1.50` on `@db.Decimal`, `@db.Decimal(10, 2)` and the default `DECIMAL(65,30)`), which is the text Prisma 7.10.0 writes into the column default. Fixture `number-defaults`. The `supported` proof schema carries the same spellings, and `test/integration/test/prisma7-source/supported.integration.test.ts` applies Prisma 7.10.0's SQL for it and runs strict `db verify`. A number with a fraction on an `Int` field (including `@db.SmallInt`) or a `BigInt` field, and a number the codec reads neither way, is `PSL.PRISMA7_UNKNOWN_DEFAULT`; the message says an `Int` or `BigInt` default must be a whole number. Prisma 7.10.0 rejects each of these (`"1.5" is not a valid integer`), for single values and list elements. Fixture `integer-default-not-whole-number`. | | `DateTime` string literal | Raw expression column default holding the text of the default Postgres stores, not the text Prisma 7 writes (`'2024-01-02 03:04:05 +02:00'`): the written date on `date`, the written wall-clock time without the offset on `timestamp` and `time`, the time with the written offset on `timetz` (`'03:04:05+02'`), and on `timestamptz` the instant in its UTC form, the text a session in UTC prints (`'2024-01-02 01:04:05+00'`, and `'0001-12-31 23:30:00+00 BC'` before year 1). A session in another time zone prints the same default differently (`-05`, or an offset with seconds such as `-04:56:02` before a zone adopted standard time), so `db verify` needs the default read back in a UTC session or compared as an instant. Fractional seconds are rounded to microseconds half to even; the column's precision does not change a stored default. The Postgres target's `test/prisma7-temporal-defaults.test.ts` pins 20 written values against the text Postgres printed for each type. Fixture `datetime-defaults` covers the interpretation, and the `supported` proof schema carries the same defaults, so `supported.integration.test.ts` runs the live check against Prisma 7.10.0's SQL, including one `timestamptz` default read back in a session whose time zone is not UTC. | | `Bytes[]` or `DateTime[]` list literal | Raw expression column default: an `ARRAY[...]` of the element literals Postgres stores, cast to the column type, for example `ARRAY['\x68656c6c6f']::BYTEA[]` and `ARRAY['2024-01-01 00:00:00']::TIMESTAMP(3)[]`, where Prisma 7 writes `ARRAY['2024-01-01 00:00:00 +00:00']::TIMESTAMP(3)[]`. Each element carries the same stored text as a scalar default, because Postgres ignores the written offset for `date`, `time`, and `timestamp` elements, so the text Prisma 7 writes does not describe the stored value. Fixture `list-defaults`. The live proof depends on the Postgres default reader understanding `'...'::timestamp(3) without time zone` elements. | | `Json` literal `"null"`, top level or as a list element | `PSL.PRISMA7_JSON_NULL_DEFAULT_UNSUPPORTED`, on required and optional fields: Prisma 7 writes `DEFAULT 'null'`, the JSON value null, and a contract literal `null` cannot be told apart from SQL `NULL`. The message says removing the default or giving another JSON value changes the column default on Prisma 7's next migration. A `null` nested inside an object or array is an ordinary JSON default. Fixture `json-null-default`. | | `dbgenerated("expr")` | Raw expression column default. | | `dbgenerated()` with no expression | Prisma 7 creates no `DEFAULT` for it. On an optional or list field it lowers to a nullable column with no default, which describes that column exactly (fixture `dbgenerated-without-expression-optional`). On a required field it is `PSL.PRISMA7_UNKNOWN_DEFAULT`, saying the form is not supported yet there, because a contract without a default makes the ORM require the value on create. The message offers two edits: remove the `@default`, which makes Prisma 7's next migration run `ALTER COLUMN ... DROP DEFAULT` (removing a default the database got some other way) and both clients require the value, or write the expression, which Prisma 7's next migration sets as the column default. Fixture `dbgenerated-without-expression`. | | `uuid()`, `uuid(4)`, `uuid(7)`, `ulid()`, `nanoid(n)` | ORM-side execution generator, no column default. On optional fields: `PSL.PRISMA7_OPTIONAL_GENERATED_FIELD_UNSUPPORTED`, which prints the default as written and advises removing it and keeping the `?` (no database change; both clients stop filling the value). | | `cuid()`, `cuid(2)` | ORM-side `cuid2` generator. | | `@updatedAt` | Execution generator on create and update, column codec `pg/timestamp-temporal@1` with `typeParams.precision = 3` (item 2 showed the precision must be a type parameter), or the `@db.*` override, no storage default. The generator is the one the target's lookup gives for the column's codec (`plainDateTimeNow` for `timestamp`, `instantNow` for `timestamptz`). The lookup lists every codec the target has a "now" generator for, including the JS `Date` and string timestamp codecs, which use `timestampNow`; every `temporal` preset takes its generator from it, and a target test fails when a preset's generator differs from the lookup's. Another test encodes the generated value through its codec where the generator makes the value that codec takes: `plainDateTimeNow` and `instantNow` for the Temporal codecs, and `timestampNow`'s `Date` for `pg/timestamptz-date@1`. The string timestamp codecs get a `Date` from `timestampNow` and pass it through unencoded; a separate test records that existing mismatch and fails once it is fixed. A column whose codec has no generator (`@db.Date`, `@db.Time`, `@db.Timetz`) is `PSL.PRISMA7_UPDATED_AT_TYPE_UNSUPPORTED` on `@updatedAt`: Prisma 8 has no generator for that column type yet, and removing `@updatedAt` gives an empty Prisma 7 migration, after which neither client fills the value. The message says what follows for the field's shape: a required field with no `@default` must then be given on create by both clients, an optional field stays empty unless a client writes it, and a field with `@default(now())` still gets a value on create from that `@default` (the Prisma 7 client writes its own timestamp in the INSERT, and Prisma 8 relies on the column default); neither client changes the value on update. Prisma 7.10.0 validates all three shapes and gives an empty migration when `@updatedAt` is removed, and a Prisma 7.10.0 client generated from the edited schema behaves as each message says against a real database. This check runs before the optional-field and `@default` checks, so it is the only diagnostic those fields get. Fixture `updated-at-without-generator`. On an optional field: `PSL.PRISMA7_OPTIONAL_GENERATED_FIELD_UNSUPPORTED`, advising to remove `@updatedAt` and keep the `?` (no database change; both clients stop filling the value). With any `@default`: `PSL.PRISMA7_UPDATED_AT_WITH_DEFAULT_UNSUPPORTED`, advising to remove the `@default` (Prisma 7's next migration drops the column default, `ALTER COLUMN ... DROP DEFAULT`). Dropping the `?` instead would declare the column `NOT NULL` against a nullable database column, which `db sign` reports. Each diagnostic points at the attribute its message says to remove; `test/integration/test/prisma7-source/generated-field-advice.integration.test.ts` removes exactly those attributes from `supported/schema.prisma` and verifies the result with zero findings against `supported/migration.sql`. Both because Prisma 8 PSL cannot express the combination, so the converter could not print it (the reasoning is in `design-notes.md`). | ### Keys, uniques, indexes `@id`, `@@id`, `@unique`, `@@unique`, `@@index` map directly. Prisma 7 creates `@unique` and `@@unique` as unique **indexes** named `{table}_{cols}_key`, not unique constraints (lowering them as constraints produced `unique:*` findings against a live Prisma 7 database), so they lower to unique indexes with those names. Plain index names are the `map` argument if given, else `{table}_{col1}_{col2}_idx`. Both patterns use the mapped column names when a field has `@map` (derived from Prisma 7's naming rule; proven by the `supported` fixture, which carries an index over a mapped column). Index `type:` maps to Prisma 8's index type. Sort order and length arguments map where Prisma 8 has them; otherwise `PSL.PRISMA7_INDEX_ARGUMENT_UNSUPPORTED`. ### Relations Explicit relations map directly, keeping relation names. `onDelete` defaults to `Restrict` when any foreign key field is required and to `SetNull` only when every one is optional, so a composite key that mixes an optional and a required field gets `Restrict`, as Prisma 7.10.0 writes it; `onUpdate` defaults to `Cascade`. Both are always set explicitly. An explicit `SetNull` (`onDelete` or `onUpdate`) over a required foreign key field, or `SetDefault` over a required field with no column default (a client-side generator such as `uuid()` gives the column none), is `PSL.PRISMA7_REFERENTIAL_ACTION_UNSUPPORTED` on the `@relation` attribute: Prisma 7.10.0 accepts both (with a warning for `SetNull`) and writes them into the foreign key, but the contract rejects them because the action would fail the first time it runs. The message offers making the fields optional (and the relation field, when it is required) or giving them a column default (`ALTER COLUMN ... DROP NOT NULL` or `SET DEFAULT` on Prisma 7's next migration) or another action (the next migration drops and re-adds the foreign key), and says what each does to the Prisma 7 client, as Prisma 7.10.0's generated client shows: optional fields become nullable; a field given a column default becomes optional when creating records; a field with a client-side generator must have its `@default` replaced, because a field takes only one, and a live insert through the Prisma 7 client then omits the column and gets the database default instead of a generated value; another action leaves the generated client unchanged apart from the schema text it embeds. Fixtures `referential-action-not-null` and `referential-action-not-null-variants`. A relation field may be optional over fields that are all required, which Prisma 7 accepts without a warning: its foreign key and its relation are those of a required relation (the relation is not nullable, because the foreign key guarantees the related row). A required relation field over an optional field is `PSL.PRISMA7_RELATION_UNRESOLVED`, as Prisma 7 rejects it ("At least one of those fields is optional. Hence the relation field must be optional as well."). Fixtures `referential-action-defaults` (checked by hand with `db verify` against Prisma 7.10.0's SQL) and `relation-nullability`. Implicit many-to-many (a list field on both sides, no junction model) becomes the junction model Prisma 7 creates: table `_AToB` with `A` and `B` the model names in alphabetical order, or `_RelationName` when the relation is named; columns `A` and `B` typed as the two ids; primary key `(A, B)`; index `_AToB_B_index` on `B`; two foreign keys with `Cascade` on both actions; two back-relation list fields. The junction model's key is `AToB`, or the relation name. Its two relation fields, over `A` and then `B`, are named as `contract infer` names the same table's foreign keys. The target binding supplies them (`junctionRelationFieldNames`); the Postgres binding runs infer's own PSL construction on a table with those two foreign keys and reads the names back, so no naming rule is copied. Infer decides each name twice, as for any foreign key: first the referenced table name in camelCase, escaped like an inferred field name, checked against the column names, with the referenced table's inferred model name and then a number appended when taken; then checked against the field names the columns `A` and `B` print as (`a`, `b`), with the first free number from 2 appended (`blogPosts` and `tag` for `_PostToTag` when `Post` maps to `blog_posts`; `user` and `userUser` for the self relation `_Follows`; `category` and `product` across two schemas; `a2` and `b2` for `_AToB` over models `A` and `B`; `a2` and `aA` for a self relation over `A`). `test/integration/test/prisma7-source/implicit-many-to-many-names.integration.test.ts` runs infer's inference on the tables Prisma 7.10.0 created for these relations, and for one relation name in two schemas, and compares the names. A user model with the junction model's name in the junction's schema (`PostToTag`, or `Favorites` next to `@relation("Favorites")`) is `PSL.PRISMA7_JUNCTION_NAME_COLLISION`, reported once on the first relation field of the pair and naming both: Prisma 7.10.0 accepts the schema and creates both tables, but the contract cannot hold two models under one key. The message says to rename the model and keep its table with `@@map`, which gives an empty Prisma 7 migration; the renamed schema was checked by hand with `db verify`, with zero findings. Fixture `junction-name-collision`. Prisma 6.0.0 introduced the primary key (item 4, resolved); databases last migrated on Prisma 5 or earlier still carry `_AB_unique` and must be migrated on Prisma 7 first. The docs say so. `@ignore` fields are kept as columns of their model's table and left out of the model ([ADR 267](https://github.com/prisma/orm/pull/30641)). The column keeps its type, nullability, list shape and column default, but gets no execution default: `uuid()`, `cuid()`, `nanoid()`, `ulid()` and `@updatedAt` are values the ORM generates, and the ORM never writes the column. Uniques and indexes over an ignored field are kept. A relation field marked `@ignore` keeps its foreign key on the model's table and stays out of the domain with its back-relation; an implicit many-to-many relation with an `@ignore` list field, or an `@@ignore` model, on either side keeps its junction table as storage with no model. Prisma 7 still creates all of these, and strict `db verify` reports nothing for them (fixtures `ignore`, `ignored-field-defaults`, `ignored-field-in-index`, `ignored-relation-field`, `ignored-relation-back-relations`, `relations-ignored`, `ignored-models`, `ignored-model-many-to-many`). An `@ignore` field in `@id` or `@@id` is `PSL.PRISMA7_IGNORED_FIELD_REFERENCED`, because without it the model has no field that identifies a row; the message offers removing `@ignore`, or replacing it with `@@ignore` on the model (fixtures `ignored-field-in-primary-key`, `ignored-id-in-implicit-many-to-many`). So is an `@ignore` field that a relation which is not `@ignore` joins on through `fields:` or `references:`, located at the `@relation`, because Prisma 8 relations join on fields; the message offers removing `@ignore` from the field, or marking the relation field `@ignore` too (fixtures `ignored-field-in-relation`, `ignored-field-in-references`). ## Error catalogue `PSL.PRISMA7_PROVIDER_MISMATCH`, `PSL.PRISMA7_RELATION_MODE_UNSUPPORTED`, `PSL.PRISMA7_VIEW_UNSUPPORTED`, `PSL.PRISMA7_UNSUPPORTED_TYPE`, `PSL.PRISMA7_NATIVE_TYPE_UNSUPPORTED`, `PSL.PRISMA7_INDEX_ARGUMENT_UNSUPPORTED`, `PSL.PRISMA7_UNKNOWN_ATTRIBUTE`, `PSL.PRISMA7_UNKNOWN_DEFAULT`, `PSL.PRISMA7_RELATION_UNRESOLVED`, `PSL.PRISMA7_OPTIONAL_GENERATED_FIELD_UNSUPPORTED`, `PSL.PRISMA7_UPDATED_AT_WITH_DEFAULT_UNSUPPORTED` (ORM-side generators such as `uuid()` on an optional field use the previous code), `PSL.PRISMA7_TABLE_COLLISION` (two models map to the same table), `PSL.PRISMA7_JUNCTION_ID_UNSUPPORTED` (an implicit many-to-many whose side has a composite id), `PSL.PRISMA7_ENUM_NAMESPACE_MISMATCH` (a column may only use an enum type from its own schema, which is what the IR can express), `PSL.PRISMA7_IGNORED_FIELD_REFERENCED` (an `@ignore`d field that a primary key uses, or that a relation which is not `@ignore` joins on; see Relations), `PSL.PRISMA7_JUNCTION_NAME_COLLISION` (a model named like an implicit junction model; see Relations), `PSL.PRISMA7_RELATION_NAME_SHARED` (one relation name on implicit many-to-many relations between different models in the same schema; see Edge cases), `PSL.PRISMA7_REFERENTIAL_ACTION_UNSUPPORTED` (`SetNull` or `SetDefault` a required foreign key field cannot take; see Relations), `PSL.PRISMA7_JSON_NULL_DEFAULT_UNSUPPORTED` (a JSON `null` default; see Defaults), `PSL.PRISMA7_UPDATED_AT_TYPE_UNSUPPORTED` (`@updatedAt` on a column whose codec has no "now" generator; see Defaults), `PSL.PRISMA7_CONTRACT_INVALID` (the backstop, located at the input path: `load` turns into this diagnostic a structured error, one with a dotted code such as the contract builder's `CONTRACT.*` or a codec's `RUNTIME.*`, thrown while it builds the contract, and a failure of the domain, storage consistency, and model storage reference checks it runs afterwards; the structural check is left to `contract emit` because it needs the target's entity kinds; the message asks the user to report the schema as a Prisma bug; any other error inside `load`, such as an `InternalError` or a `TypeError`, still throws, because it is a bug and not a problem in the schema, as ADR 245 requires; `test/provider.test.ts` covers the builder error, the checks, and the rethrow). Each has a fixture, and each has an entry in `docs/reference/error-reference.md`. A new code needs all three. Every edit a message offers is a Prisma 7 schema change that Prisma 7's next migration applies, so the message says what that migration does, checked with `prisma@7.10.0 migrate diff`. `PSL.PRISMA7_UNSUPPORTED_TYPE` for `Unsupported(...)` and `PSL.PRISMA7_NATIVE_TYPE_UNSUPPORTED` say that Prisma 8 has no codec for the column type yet and cannot read the schema until it has one, on an `@ignore` field and in an `@@ignore` model too, because the contract keeps those columns. They offer no `@ignore` or `@@ignore`. `PSL.PRISMA7_UNSUPPORTED_TYPE` says that removing the field drops its column (fixtures `unsupported-type`, `unsupported-type-model-ignored`); `PSL.PRISMA7_NATIVE_TYPE_UNSUPPORTED` says that changing the field's type changes the column type (`ALTER COLUMN ... SET DATA TYPE`; fixtures `native-type-rejected-*`, `native-type-model-ignored`). Advice to remove `@ignore` says the field appears in the Prisma 7 client again, and advice to add `@ignore` to a relation field says it disappears from the Prisma 7 client, as Prisma 7.10.0's generated client shows. A key, index, or relation over a field whose type or attributes were already reported reports nothing of its own. `PSL.PRISMA7_RELATION_MODE_UNSUPPORTED` says removing `relationMode` or setting `"foreignKeys"` makes the next migration add the foreign keys (`ADD CONSTRAINT ... FOREIGN KEY`), which fails on any row that breaks one. The shared pairing helper reports its own `PSL_` codes; the interpreter lists the six it maps (`RELATION_PAIRING_CODES` in `relations.ts`) and reports each as `PSL.PRISMA7_RELATION_UNRESOLVED`. `test/relation-pairing-codes.test.ts` drives every diagnostic branch of the helper and fails if it emits a code outside that list, so a rename in `contract-psl` cannot leak a `PSL_` code. `PSL.PRISMA7_JUNCTION_ID_UNSUPPORTED` covers an implicit many-to-many relation on a model without a single-field `@id`, which Prisma 7 forbids too (fixture `junction-composite-id`). `PSL.PRISMA7_SCHEMA_READ_FAILED` reports an unreadable input path, or a schema directory that holds no `.prisma` file, located at the input path (`test/provider.test.ts`). ## Edge cases | Case | Disposition | |---|---| | A model `@@map`ped to the same table as another | `PSL.PRISMA7_TABLE_COLLISION`, both spans. | | A model `@@map`ped to the table of an implicit many-to-many relation (`@@map("_PostToTag")` next to `Post.tags`/`Tag.posts`) | `PSL.PRISMA7_TABLE_COLLISION` on the model's `@@map` and on the relation field, naming both. Prisma 7.10.0 validates the schema, but its migration creates only the relation's `_PostToTag` and never the model's table. Renaming the model's table with `@@map` makes Prisma 7's next migration create it (`CREATE TABLE`), and that schema was checked by hand with `db verify`, with zero findings; renaming the relation instead rebuilds `_PostToTag` as the model's table (dropping `A` and `B`) and creates an empty table for the relation. Fixture `junction-table-collision`. | | A model `@@map`ped to a table named like an implicit many-to-many relation's table, in a different schema (`Tagging` with `@@map("_PostToTag")` and `@@schema("two")`, next to `Post` in `one` and `Tag` in `two`) | Supported. Prisma 7.10.0 creates the relation's table in the first model's schema, `"one"."_PostToTag"`, and the model's table `"two"."_PostToTag"`, so the collision check compares the schema as well as the table name. Fixture `junction-table-name-in-other-schema`, checked live with `db verify` (lenient and strict), with zero findings. | | One relation name on implicit many-to-many relations between different models in the same schema (`@relation("X")` on A–B and on C–D) | `PSL.PRISMA7_RELATION_NAME_SHARED` on the first relation field of each relation, naming the others. Prisma 7.10.0 validates the schema but creates a single `_X` table whose foreign keys reference only one pair (which pair depends on declaration order in ways the probes did not settle), so the message says the table's foreign keys show which. Renaming a relation `_X` does not reference makes the next migration create its own table (`CREATE TABLE "_Y"`), and that schema was checked by hand with `db verify`, with zero findings; renaming the referenced one drops and re-adds `_X`'s foreign keys against the other models. Fixture `relation-name-shared`. | | One relation name on implicit many-to-many relations in two schemas (`@relation("X")` on A–B in `@@schema("one")` and on C–D in `@@schema("two")`) | Supported. Prisma 7.10.0 creates `"one"."_X"` wired to A and B and `"two"."_X"` wired to C and D, so the interpreter keys junctions by schema and name and lowers one table in each schema. Fixture `relation-name-in-two-schemas`, checked live with `db verify` (lenient and strict), with zero findings. | | A model named like an implicit junction model (`PostToTag`, `Favorites`) | In the junction's schema, `PSL.PRISMA7_JUNCTION_NAME_COLLISION` on the relation field; rename the model and keep its table with `@@map`. In another schema it is supported: Prisma 7.10.0 creates `"one"."_PostToTag"` and `"two"."PostToTag"`, and the contract holds each model in its own namespace. Fixture `junction-name-in-other-schema`. | | Enum inside a `@@schema` namespace | Prisma 7 creates the type in that schema (`CREATE TYPE "audit"."AuditAction"`); the native enum entity is placed in the same namespace. | | `@default(ENUM_MEMBER)` on a native enum field | Column default with the member's storage value. Test pins it. | | `@db.Timestamptz(n)` with `@updatedAt` | Generators as above, column `timestamptz(n)`. | | Self-referential implicit many-to-many | Junction `_RelationName` is required by Prisma 7; use it. Column `A` belongs to the side with the smaller model name, or for a self relation the smaller field name by plain string comparison, per prisma-engines `psl/parser-database/src/relations.rs` (`ingest_relation`). Pinned by `test/junction-sides.test.ts`. | | Multi-file directory with a `datasource` in one file | The provider check runs once across the merged document. | | A schema directory with a subdirectory named `x.prisma`, or with `.prisma` files and directories reached through symbolic links | Only regular files are read, following symbolic links; the subdirectory is skipped, as Prisma 7.10.0 skips it. Pinned by `test/provider.test.ts`. | | An empty schema directory | `PSL.PRISMA7_SCHEMA_READ_FAILED` located at the input path; Prisma 7.10.0 itself panics (`psl::validate_multi_file() must be called with at least one file`). | | `previewFeatures` other than `multiSchema` | Ignored. | ## Slice Definition of Done Inherits `drive/calibration/dod.md`. Slice-specific: - [ ] Every rule row and every error code has a fixture under the package's `test/fixtures/` that runs through `parse()` and the interpreter, and an entry in `docs/reference/error-reference.md`. - [ ] Verification items 1, 2, 3, 4, 6, and 7 each have a test or a quoted fixture committed before the dependent rule. - [ ] End-to-end proof: a fixture `schema.prisma` and the `migration.sql` Prisma 7 generated for it (README says how), applied with `pg` against `withDevDatabase`, then `contract emit`, `db sign`, `db verify` with zero findings. Covers: every scalar, `@db.*` overrides, native enum, implicit many-to-many, `@updatedAt`, multiSchema. - [ ] `architecture.config.json` lists the new package; `pnpm lint:deps` clean. - [ ] No dependency on `prisma`, `@prisma/prisma7`, `@prisma/get-dmmf`, `@prisma/prisma-schema-wasm`. - [ ] `packages/3-extensions/postgres` config reference documents `prisma7Schema`.