Skip to content

Commit 04964e8

Browse files
sorenbsclaude
andcommitted
docs: five-minute path, forward-reference pass, backlog polish
The overview page now runs the whole loop inline: three commands with the verified plan and apply output and an explicit success signal, so a newcomer is productive before leaving page one. Swept all six pages for forward references: terms like ledger, marker, and contract space are now glossed or linked at first use instead of assuming later sections. Also links the graph page from the Prisma Next index bullet, links the contract to Data Modeling, and straightens the branch/merge lanes in the migration-graph animation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent d9ed6b2 commit 04964e8

7 files changed

Lines changed: 42 additions & 18 deletions

File tree

apps/docs/content/docs/orm/next/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Prisma's current architecture tightly couples three layers: the schema language,
2525

2626
- **Better queries**: a cleaner API with simpler nested queries, custom collection methods on your models, and streaming results, plus a low-level, type-safe SQL query builder for the cases that need raw control.
2727
- **Extensible by design**: a minimal core exposed through a public SPI. Everything around it, including Postgres support itself, is an extension, so you can add databases, query builders, data types, and middleware.
28-
- **Rethought migrations**: graph-based migrations that resolve branch conflicts automatically and make partial failures safe to retry, with both schema and data migrations written in TypeScript and validated against your contract.
28+
- **Rethought migrations**: [graph-based migrations](/orm/next/migrations/the-migration-graph) that resolve branch conflicts automatically and make partial failures safe to retry, with both schema and data migrations written in TypeScript and validated against your contract.
2929
- **AI-agent friendly**: your schema compiles to a machine-readable contract, every query produces a structured, inspectable plan, and middleware adds compile-time guardrails. The installers also register agent skills so your editor's AI assistant can drive Prisma Next changes safely.
3030

3131
## How it works

apps/docs/content/docs/orm/next/migrations/applying-a-migration.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ App space
3535
Next: prisma-next migration status
3636
```
3737

38+
`App space` is your application's migration lane, one of the run's *contract spaces*; projects that use database extensions gain additional spaces, covered in [Extension spaces](#extension-spaces) below.
39+
3840
## Check before, preview, then apply
3941

4042
The habit worth building, especially against shared databases, is a three-step rhythm:

apps/docs/content/docs/orm/next/migrations/generating-a-migration.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ We'll start from a minimal project. If you don't have one, `npx create-prisma@ne
1313

1414
## Your first migration
1515

16-
Say your contract has a single model:
16+
Say your [contract](/orm/next/data-modeling) has a single model:
1717

1818
```prisma title="contract.prisma"
1919
model User {
@@ -66,6 +66,7 @@ Three things to notice:
6666
- **The DDL preview is right there.** You see the exact SQL before anything exists but files.
6767
- **`from: null`** means this migration starts from an empty database; it's the root of your [migration graph](/orm/next/migrations/the-migration-graph).
6868
- **`to:` is your contract's hash.** The migration promises to deliver a database matching exactly the contract you just emitted.
69+
- **`App space`** is your application's migration lane. Database extensions bring their own lanes; see [extension spaces](/orm/next/migrations/applying-a-migration#extension-spaces).
6970

7071
The planned migration directory contains the TypeScript source, the compiled operations, and the contract snapshots:
7172

apps/docs/content/docs/orm/next/migrations/how-migrations-work.mdx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,34 @@ The workflow is a loop you will run many times a day in development:
1818
3. **Review it**: read the generated TypeScript and the DDL preview. Edit the migration if the change needs a data step, then re-run the file to recompile it.
1919
4. **Apply it**: `prisma-next migrate` runs the pending migrations against your database.
2020

21+
In a project with a database connection configured (the [quickstart](/next/quickstart/postgresql) gives you one), the whole loop is three commands. Add an optional `phone String?` field to a model in your `.prisma` file, then:
22+
2123
```bash
2224
npx prisma-next contract emit
2325
npx prisma-next migration plan --name add_user_phone
2426
npx prisma-next migrate
2527
```
2628

27-
Each page in this section walks through one part of the loop in detail. This page covers the model: what a migration is, and why it looks the way it does.
29+
`migration plan` prints the SQL it wrote before anything runs:
30+
31+
```text
32+
✔ Planned 1 operation(s)
33+
34+
35+
└─ Add column "phone" to "user"
36+
37+
DDL preview
38+
39+
ALTER TABLE "public"."user" ADD COLUMN "phone" text;
40+
```
41+
42+
and `migrate` confirms what it applied:
43+
44+
```text
45+
✔ Applied 1 migration(s) (1 operation(s)) across 1 contract space(s)
46+
```
47+
48+
(The contract-space count only matters once you add database extensions; ignore it for now.) If you see that `✔ Applied` line, you've already run the entire workflow; the rest of this section is detail. This page covers the model: what a migration is, and why it looks the way it does.
2849

2950
## What a migration is
3051

@@ -121,7 +142,7 @@ Two commands talk to a database:
121142
| ------------------ | ---------------------------------------------------------------------------- |
122143
| `migrate` | [Apply pending migrations](/orm/next/migrations/applying-a-migration) |
123144
| `migration status` | Show where the database is in the graph and which migrations are pending |
124-
| `migration log` | Show the history of applied migrations from the database's ledger |
145+
| `migration log` | Show the history of migrations the database has actually applied |
125146

126147
Note that applying is `prisma-next migrate`, not `migration apply`: `migration ...` commands manage the on-disk migration directories, while `migrate` moves a database.
127148

apps/docs/content/docs/orm/next/migrations/rollbacks-and-recovery.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Two different situations get called "rollback", and Prisma Next treats them diff
1414

1515
## Rollback: a migration like any other
1616

17-
There is no `migrate down` command, and no separate "down migration" files. In the [graph model](/orm/next/migrations/the-migration-graph), the state you want to return to is a node you've already visited, so rolling back means planning a new edge that points at it. If you know git, this is `git revert`, not `git reset`: history only ever grows, and the ledger keeps a full record of the round trip.
17+
There is no `migrate down` command, and no separate "down migration" files. In the [graph model](/orm/next/migrations/the-migration-graph), the state you want to return to is a node you've already visited, so rolling back means planning a new edge that points at it. If you know git, this is `git revert`, not `git reset`: history only ever grows, and the ledger (the applied-history record every database keeps) retains the full round trip.
1818

1919
<ConceptAnimation name="migration-rollback" />
2020

@@ -60,7 +60,7 @@ Afterwards the graph shows the round trip: a forward edge up, a rollback edge ba
6060
* -
6161
```
6262

63-
The database's marker is back at `705b1a6`, and the ledger records both the apply and the rollback. Nothing was rewritten or deleted.
63+
The database's marker (its record of which graph node it currently matches) is back at `705b1a6`, and the ledger records both the apply and the rollback. Nothing was rewritten or deleted.
6464

6565
Two things to be clear-eyed about:
6666

apps/docs/content/docs/orm/next/migrations/the-migration-graph.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ npx prisma-next migration graph
4444
1 space(s), 5 contract(s), 5 migration(s)
4545
```
4646

47-
This project's history is a diamond. Read it bottom-up: from an empty database (`-`), `init` establishes state `789dd79`. Alice and Bob branch from it in parallel: she adds a phone column, he adds an avatar. Then each branch gets a merge migration into the combined state `f9a41d7`, which the `prod` ref points at.
47+
This project's history is a diamond. Read it bottom-up: from an empty database (`-`), `init` establishes state `789dd79`. Alice and Bob branch from it in parallel: she adds a phone column, he adds an avatar. Then each branch gets a merge migration into the combined state `f9a41d7`, which the `prod` ref points at. (The summary line counts contract *spaces*: independent migration lanes, one for your app plus one per [database extension](/orm/next/migrations/applying-a-migration#extension-spaces).)
4848

4949
## What the graph gives you
5050

apps/docs/src/components/concept-animation/presets.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ export const CONCEPT_PRESETS = {
224224
{
225225
title: "2. Two people branch",
226226
code:
227-
"[[* 93be6c2 * 7e3fa7f]]\n" +
228-
"[[|^ alice_phone |^ bob_avatar]]\n" +
229-
" \\ /\n" +
230-
" * 9f49f8f ← both branched from here\n" +
227+
"[[* 93be6c2]] [[* 7e3fa7f]]\n" +
228+
"[[|^ alice_phone]] [[|^ bob_avatar]]\n" +
229+
" \\ /\n" +
230+
" * 9f49f8f ← both branched from here\n" +
231231
" |^ add_posts\n" +
232232
" * 705b1a6",
233233
caption:
@@ -236,13 +236,13 @@ export const CONCEPT_PRESETS = {
236236
{
237237
title: "3. The branches merge",
238238
code:
239-
" * [[f9a41d7 (prod)]]\n" +
240-
" / \\\n" +
241-
"[[|^ merge_alice |^ merge_bob]]\n" +
242-
" * 93be6c2 * 7e3fa7f\n" +
243-
" |^ alice_phone |^ bob_avatar\n" +
244-
" \\ /\n" +
245-
" * 9f49f8f",
239+
" * [[f9a41d7 (prod)]]\n" +
240+
" / \\\n" +
241+
"[[|^ merge_alice]] [[|^ merge_bob]]\n" +
242+
"* 93be6c2 * 7e3fa7f\n" +
243+
"|^ alice_phone |^ bob_avatar\n" +
244+
" \\ /\n" +
245+
" * 9f49f8f",
246246
caption:
247247
"After the git merge, each branch gets a small merge migration into the combined state. A database that followed Alice takes merge_alice; one that followed Bob takes merge_bob. Every environment finds its own path.",
248248
},

0 commit comments

Comments
 (0)