Repository navigation
feat(postgres)!: split the marker into per-space signatures and per-database policies, in a schema named prisma - #31242
Open
wmadden-electric wants to merge 92 commits into
Open
wmadden-electric wants to merge 92 commits into
wmadden-electric wants to merge 92 commits into
Conversation
…tures and configuration Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…es signatures and config, and moves a release candidate's marker into them The space's contract now describes _prisma.signatures (one row per space, without the columns nothing reads), _prisma.config (one row for the database, keyed by a boolean that a check holds true) and the unchanged ledger and contract. The first migration is rewritten in place, since no release has recorded it: after renaming prisma_contract it checks the release candidates' marker, then moves its rows into signatures, the application row's policies into config, and drops it, in one step that is skipped once the marker is gone. The space's contract lists the two capabilities its tables use, since a config built without the PostgreSQL defineConfig gets no default list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ger and contract, and a run that changes only the policies writes config The runner's check for Prisma's own tables now names each table that is missing, not only the marker. A run whose only change is the database's policies records them as the one row of _prisma.config and writes no signature, so signed_at says when a space was last signed. The statement that records the policies is one constant beside the table names, which the adapter uses too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…_prisma.signatures, and the policies are written to _prisma.config The control adapter reads and writes each space's row in _prisma.signatures, whose signed_at it reads as the record's updatedAt, and names that table in its marker location, so a corrupt row names it. Given policies, initMarker and updateMarker record them as the one row of _prisma.config in the same transaction, updateMarker only once the signature has moved. Reading the policies back is not part of this change. The tests read the new tables. Two runner tests of the policies held under the lock read _prisma.config and fail until the commands read the policies from it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…natures and _prisma.config The tests that read or write the application's signature now name _prisma.signatures, seed and create it without the columns it dropped, and the upgrade journey checks that a release candidate's rows and policies are moved. The journey's check that a migrate-only release candidate database refuses db update fails until the commands read the policies from _prisma.config. 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.config on PostgreSQL; ADR 042 is superseded by ADR 339 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…into dist The SQL runtime and the emitter publish test/utils.ts as a built entry point. It was not among the build inputs, so a change to it alone restored the cached dist, and integration tests ran the old helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…olicies; a new slice gives them a channel of their own Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…the release candidates shipped Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…icies of _prisma.config as meta.policies The commands read the policies from the application space's record, and the signatures row has no meta, so every PostgreSQL database read as having the default policies. Each read of signatures now joins config in the same statement, so the signature and the policies come from one state. The stored value is passed on unparsed, for the framework's parser and its corrupt-policies error. Other spaces never carry policies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… initMarker writes to _prisma.config The test expected the application space's record to carry no policies, which is the defect the previous commit fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ignatures and _prisma.config, not _prisma.marker The instructions say the first command moves the marker rows into signatures and the policies into config, that grants on the marker are dropped with it and the application role needs SELECT on both new tables, and that Prisma Studio 0.36.0 reads _prisma. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…policies are in _prisma.config Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…_prisma.config on PostgreSQL Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…onfig move Name the two warnings a client without SELECT on the new tables logs, say that keys other than policies in meta are not moved, that the move also drops marker, which needs ownership, and which releases recorded policies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…gnatures finds no marker Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ramework, and what a missing application row means for them; slice 3 lands before 8.0.0 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… and the Prisma space row is read through its four fixed columns The SQL client check on first use compares hashes, so it now reads the signature without _prisma.config, and a role needs SELECT on _prisma.signatures only. The Prisma space own row is read through space, core_hash, profile_hash and invariants and nothing else, by the phase and by readAllMarkers, so a later release may drop signed_at or reshape _prisma.config without an 8.x release failing to recognise the row. The control commands read the policies only when _prisma.config has its policies column; a database without it reads as recording no policies. The policies stay in the same statement as the signature, so both come from one state. Policies stored as JSON null are handed to the framework as null, as a release candidate marker handed them, so they are still reported as unreadable instead of reading as the defaults. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… Prisma space contract Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… of the marker table, and stops naming the objects that depend on it The ownership check of prisma_contract.marker now gives the real reason: this migration drops the table, and dropping a table needs the owner privileges. The ledger and contract tables keep their reason. A view, function or other object that depends on prisma_contract.marker made DROP TABLE fail after the rename, with a message about _prisma.marker, a table that no longer exists once the transaction rolls back. A precheck on the rename now stops first. A step whose meta names tableDependents makes the runner list the dependent objects from pg_depend, in the words PostgreSQL uses, and the check says to drop them and create them again over _prisma.signatures. The migration hash changes; ops.json and migration.json are re-emitted. The head ref and snapshot hold the contract hash, which is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…greSQL marker location Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…config moved after they were checked Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e land in _prisma.config and refuse a later db update Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…sma.signatures alone, and the move stops when another object depends on marker Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ated 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]>
…to read the policies instead of reading the defaults Whether _prisma.config and its policies column exist was read from information_schema.columns, which lists only the columns the role may use. A role without SELECT on config therefore read no policies and got the defaults, so a database that permits only migrate accepted db update from it. The columns now come from pg_attribute, which lists them whatever the role may do, so the read that follows selects policies and PostgreSQL refuses it, reported as CONTRACT.MARKER_READ_FAILED. The column check of the Prisma space row reads the catalogue the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Conflicts kept both sides: the CLI options take the Prisma space listener and the unrecorded-snapshot listener, and db update reports both the Prisma space and an unreadable origin snapshot. api-breaks.json records from both sides are kept, their reasons joined and fingerprints taken from the merged api.txt. main moved APP_UPGRADE_GUIDES_URL to @internal/utils/upgrade-guides, so the CLI imports it from there and @internal/errors/control no longer re-exports it. contractSpaceFromJson now takes the space id, and assertDescriptorSelfConsistency the bundled contract.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… version 1 The contract and the migration are re-emitted, and the head ref and the snapshot rewritten by the format-version upgrade script. No hash changed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ma's tables and checks prisma_contract before the rename The check that schema prisma holds only Prisma's tables takes the schema as Prisma's when its signatures table has the columns every 8.x release reads, so a rerun against a later release's tables passes. The rename first checks that prisma_contract holds only the release candidates' tables. A step names what a schema may hold as data (meta.schemaHoldsOnly), and the runner owns the query that lists the other objects. An empty prisma needs USAGE and CREATE on it, not its ownership. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e in location 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]>
… points to no upgrade instructions Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…age a project's own prisma gives Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…sma, and how the first migration stays rerunnable Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
_prisma.signatures and _prisma.configprisma
… the migrating role needs, and that the refusal is by schema Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ithout the columns Prisma reads, and an empty prisma is adopted without CREATE on the database Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ls its extension Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… the release candidates' tables whatever columns a project added The check named a release candidate's ledger, contract or marker with an added column as an object Prisma did not create, and advised moving or dropping it, which would lose Prisma's records. It now accepts those three tables by name, with their sequences, indexes and constraints, and leaves their form to the checks of their columns, which accept extra columns. The upgrade instructions say never to drop them to get past the check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ink only when it can fail on a new database The check that schema prisma is Prisma's can fail on a new database, where no upgrade instructions apply. The checks of the operation that brings a release candidate's database up to date (what prisma_contract holds, and what depends on its marker) fail only during an upgrade, so they lead with the objects they found and keep the link to the upgrade instructions. The branch is chosen by the failed check's operation id, which the failure carries. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ma schema yet Studio 0.36.0 reads _prisma, which no release of Prisma uses. The release that reads prisma is the one after prisma/studio#1615 merges; until then the Migrations view is empty on an upgraded database. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e upgrade instructions Shared CLI code must not name a PostgreSQL operation id, so the branch on the failed check's operation id is gone. A check that names objects still leads with them; every check keeps the link to the upgrade instructions. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as ready for review
November 29, 2026 01:14
wmadden-electric
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as draft
November 29, 2026 01:22
wmadden-electric
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…en a project added a column to the release candidates' marker The migration copies the rows of prisma_contract.marker into signatures and config, which keep only some of its columns, and then drops it. Since the rename's check accepts the release candidates' tables in any form, a column a project added to marker, and its data, were lost without a message. The rename now checks first that marker has no columns but the release candidates'. The runner names each other column, and the check's description says to copy its data elsewhere and drop it, with the statements. ledger and contract are still kept with any column a project added. The check's description, the error reference and the app upgrade instructions no longer say all three tables are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as ready for review
November 29, 2026 01:33
wmadden-electric
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
added a commit
that referenced
this pull request
Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as draft
November 29, 2026 01:38
…umns ends by saying it found such columns The CLI appends "In this database, those objects are ..." to the description of a check that names objects. The description of the check on prisma_contract.marker's columns ended with "then run the command again.", so that sentence referred to nothing. It now ends "This command found such columns there.", as the other object-naming checks do. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as ready for review
November 29, 2026 01:44
…nto own-tables-signatures-config Prisma's own contract and its first migration are re-emitted under the new hash rules: storage hash a09d7307, migration hash 1937b046. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At a glance
Prisma's bookkeeping table
markeris split in two, and Prisma's own schema is namedprisma. A database a release candidate set up, before and after its firstprisma db migratewith this release (hashes shortened):What the terms mean:
ledger(one row per migration applied), andcontract(the contracts those migrations moved between, read by Prisma Studio).db signwrites it, and every command reads it first.db migrate, bydb updateor by both, and whether a change may lose data. They were in themetacolumn of the application's row._prismarow is the signature of a contract space for Prisma's own tables, which brings those tables up to date with migrations the PostgreSQL package carries (feat(postgres)!: Prisma's own tables move to schema_prismaand are brought up to date before every command that changes a database #31234)._prismais a value in thespacecolumn, not a database object.contract_json,canonical_versionandapp_tag(nothing read them; every writer wroteNULL) andmeta(its only content, the policies, is inconfig).updated_atis nowsigned_at.Breaking for a project on a release candidate that:
SELECTonprisma.signatures, and a role that runs Prisma's commands also needs it onprisma.config;markerin its own SQL, or built a view or function over it;prisma.Each is covered below. The PostgreSQL target package's exports change too.
The decisions
Three, all made before any release ships these tables:
prisma.signatureshas one row per space andprisma.configone row per database.signatures. "Marker" says nothing to someone who finds the table in their database. "Signature" matchesdb sign, which writes the row. Error codes such asCONTRACT.MARKER_MISSINGstill say "marker"; renaming the concept everywhere a user sees it is a later change, also before8.0.0.prisma. feat(postgres)!: Prisma's own tables move to schema_prismaand are brought up to date before every command that changes a database #31234 renamed the release candidates'prisma_contractto_prisma. This change names itprismainstead, so every name Prisma puts in a database isprismaorprisma_<what it is>, on every database. On databases without schemas (SQLite, MySQL, MongoDB) the tables will beprisma_signatures,prisma_configandprisma_ledgerwhen they move to this design. The tool's own name is how most tools name theirs (django_migrations,knex_migrations, Drizzle's schemadrizzle).Why now: within Prisma 8, Prisma's own tables may only gain columns and tables, never lose or rename them, so that a release can always read a database a later release of the same major has touched. And every release finds the
_prismarow, and from it the form of Prisma's tables, in this table, throughspace,core_hash,profile_hashandinvariants. After8.0.0the table could not be renamed,metacould not be dropped, and that row could not move. A test pins those four columns.How it merges
This pull request is stacked on #31234, which makes Prisma's tables a contract space and renames their schema. The two must ship in the same release, and
mainmust be releasable at any time, so neither may reachmainalone. When approved, this one merges into #31234's branch, and #31234 then brings both intomain, after #31203 (which changes how every contract hash is computed; Prisma's own contract hash must be final before a release records it). No release has shipped #31234's migration of Prisma's tables, so this change rewrites that migration in place.How a database is upgraded
Prisma's own tables are created and changed by their own migrations, which every
db init,db update,db migrateanddb signapplies before it reads anything. On a release candidate's database the first of those migrations renamesprisma_contracttoprisma, copies eachmarkerrow intosignatures, copies the application row's policies intoconfigexactly as stored, and dropsmarker, in one transaction. A second command running at the same time finds the work done and skips it. Nothing is asked of the user.A project's own schema named
prismaPrisma never shares its schema:
MIGRATION.PRECHECK_FAILED, changing nothing, whenprismaholds anything besides Prisma's own tables. The message names each object, read from the catalogue so a role's privileges cannot hide one. Onceprisma.signaturesexists with the four columns above, the schema counts as Prisma's, so a later release that adds columns or tables can still rerun the migration. Ifprismaexists but is empty, and the role running migrations may create objects in it, Prisma uses it.prisma_contractis checked the same way before it is renamed. Itsledgerandcontract, which are kept, count as Prisma's whatever columns a project added to them; anything else is named. Itsmarkeris copied and dropped, so a column a project added to it stops the command, which names the column and says to move that data first.prismaorprisma_contract: planning it and applying it are refused, with a message saying the name is reserved for Prisma's own tables.db signanddb verifydo not check this; for either to accept such a contract, a project would already have put its own tables inside Prisma's schema by hand.One case needs action from the user. PostgreSQL's default search path is
"$user", public, so for a connection whose role is namedprisma, the schemaprismabecomes the current schema once it exists. Prisma's own SQL names its schemas and is not affected. Other tools and raw SQL run as that role, naming tables without a schema, would look inprismafirst. Such a project sets the role's search path:ALTER ROLE prisma SET search_path = public.Who reads and writes the policies
The commands that change them write them into
prisma.config:db migrate --to <ref> --permit-policy-changeanddb update --to <ref> --permit-policy-changewrite the policies a ref (a named pointer file undermigrations/) declares, in the same transaction as the run.Every command that obeys them reads them, and so does the runner (the code that applies migrations), which checks under its lock that they did not change mid-run. That code is shared by every database and expects the policies on the application's signature, as
meta.policies. This change leaves it alone: the PostgreSQL adapter readsprisma.configand hands the value over in that shape. The next slice of this project, which must also land before8.0.0, gives the policies their own path through the shared code. Until then:signaturesreads as having the default policies, even ifconfigrecords stricter ones. That happens only when someone deletes that row by hand, since every write ofconfigalso writes it.A policy read never falls back to the defaults on an error: a role that may not read
config, or that row-level security onconfigapplies to, getsCONTRACT.MARKER_READ_FAILEDnamingprisma.config.What a user changes
GRANT SELECT ON prisma.signatures TO <role>;. On first use the client checks that the database's signature matches the contract the application carries, and logs a warning if not. It reads onlysignatures. A grant on the oldprisma_contract.markerdoes not carry over, because that table is dropped; without the new grant the client logsCONTRACT.MARKER_MISSINGonce (the code's name is a leftover) and its queries still run.db verify,migration status, and every command that changes the database) also needsSELECTonprisma.config, because those commands read every signature and the policies in one read. This is new; the next slice lets the commands that do not use the policies skip them.markerreadsprisma.signatures, orprisma.configfor the policies.prisma_contract.marker(including one that uses the table's row type, such as a function takingmarker[]) stops the upgrading command before anything changes. The message names each object with its schema, for exampleview public.marker_view.markerwould let the copy read fewer rows than exist, so the upgrading command stops first and gives the statement that lifts it.The upgrade instructions an agent follows are in
upgrade-instructions/pending/prisma-tables-in-prisma-schema/(the whole upgrade, for applications and extension authors) andupgrade-instructions/pending/prisma-signatures-and-config/(a project's code and docs that name the marker table). Prisma Studio reads onlyledgerandcontract; prisma/studio#1615 makes it read them fromprisma, and must be released before the ORM release.Also in this change
tableDependents,schemaHoldsOnlyandtableHoldsOnlyColumns, are declared to the reader of stored migrations; each holds only data (a schema, a table, the tables a schema or the columns a table may hold), and the runner owns the catalogue queries that use it. The rule for stored files is that a reader acting on a new field raises the format version; format 1 is not final until8.0.0, so these fields are part of it.turbo.json:test/utils.tsis a build input. Two packages compile it intodist, and a change to it alone restored a cached, stale build.prisma; those on the marker's storage (ADR 021), the policies (ADR 320), contract spaces (ADR 212) and Prisma's own tables (ADR 339) are corrected in place; ADR 042, which evolved the marker through a version field, is marked superseded.API changes
All in
@prisma/orm-target-postgres, used by the PostgreSQL adapter and runner, which are separate packages, so these must be exported:PRISMA_TABLES_SCHEMAis"prisma".PRISMA_TABLE_NAMESlistssignaturesandconfigin place ofmarker.prismaTablesMissingSummarytakes the tables that are missing, so the runner's message names them.qualifiedPrismaTablealso acceptsRELEASE_CANDIDATE_MARKER_TABLE(new), the release candidate'smarker, which the adapter probes for.prismaTableLocation(new) gives a table's qualified name for messages.RECORD_DATABASE_POLICIES_SQL(new) is the statement the adapter and the runner both use to writeconfig.PostgresControlAdapter.readSignatureDiscriminated(new) is the client's first-use read, ofsignaturesalone.The next slice removes
RECORD_DATABASE_POLICIES_SQLandRELEASE_CANDIDATE_MARKER_TABLEwhen the policies get a single writer, as a recorded break.How it was checked
Many integration test files were changed only for the new names and not run locally; pull request CI skips integration tests, so they first run when #31234 enters the merge queue. Everything below was run:
8.0.0-rc.25, twelve scenarios, including: a new database; a release candidate's database with policies, an extension's row and a view over the marker, upgraded by this branch's command-line tool; read-only commands before the upgrade; a role that does not own the old schema; a refuseddb update; a project's ownprismaschema on a new database; a contract that declares namespaceprisma.signatures, and the upgrade journey through the commands.Alternatives considered
8.0.0it could not be changed.markerand only addconfig. Rejected: the name is fixed from here on, and it tells a reader nothing.prisma_contract. Rejected: it names one table's purpose, not the tool, and it would be the one name outside the rule every other database follows._prisma, as feat(postgres)!: Prisma's own tables move to schema_prismaand are brought up to date before every command that changes a database #31234 did. Rejected: the tool's name already says whose the objects are, the underscore only says "private" about tables users are told to read, and a collision with a project's ownprismastops safely. Its one real gain is the search-path case above, which a project fixes with one statement.configtable, one row per setting. Rejected: the policies already have one stored form, the JSON a ref declares; a single row keeps it.Agent: laozi-26
🤖 Generated with Claude Code