You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,83 +14,129 @@ To get started with Prisma Migrate in a development environment:
14
14
15
15
1. Create a Prisma schema:
16
16
17
-
```prisma file=schema.prisma showLineNumbers
18
-
datasource db {
19
-
provider = "postgresql"
20
-
}
21
-
22
-
model User {
23
-
id Int @id @default(autoincrement())
24
-
name String
25
-
posts Post[]
26
-
}
27
-
28
-
model Post {
29
-
id Int @id @default(autoincrement())
30
-
title String
31
-
published Boolean @default(true)
32
-
authorId Int
33
-
author User @relation(fields: [authorId], references: [id])
34
-
}
35
-
```
17
+
<TabbedContentcodegroupId="schema">
18
+
<TabItemvalue="Prisma 7">
19
+
20
+
```prisma file=schema.prisma showLineNumbers
21
+
datasource db {
22
+
provider = "postgresql"
23
+
}
24
+
25
+
model User {
26
+
id Int @id @default(autoincrement())
27
+
name String
28
+
posts Post[]
29
+
}
36
30
37
-
:::tip
31
+
model Post {
32
+
id Int @id @default(autoincrement())
33
+
title String
34
+
published Boolean @default(true)
35
+
authorId Int
36
+
author User @relation(fields: [authorId], references: [id])
37
+
}
38
+
```
38
39
39
-
You can use [native type mapping attributes](/orm/prisma-migrate/workflows/native-database-types) in your schema to decide which exact database type to create (for example, `String` can map to `varchar(100)` or `text`).
author User @relation(fields: [authorId], references: [id])
63
+
}
64
+
```
50
65
51
-
```terminal
52
-
prisma migrate dev --name init
53
-
```
66
+
</TabItem>
67
+
</TabbedContent>
54
68
55
-
</cmd>
69
+
:::tip
56
70
57
-
<cmdResult>
71
+
You can use [native type mapping attributes](/orm/prisma-migrate/workflows/native-database-types) in your schema to decide which exact database type to create (for example, `String` can map to `varchar(100)` or `text`).
58
72
59
-
```sql no-copy
60
-
-- CreateTable
61
-
CREATETABLE "User" (
62
-
"id"SERIAL,
63
-
"name"TEXTNOT NULL,
64
-
65
-
PRIMARY KEY ("id")
66
-
);
67
-
-- CreateTable
68
-
CREATETABLE "Post" (
69
-
"id"SERIAL,
70
-
"title"TEXTNOT NULL,
71
-
"published"BOOLEANNOT NULL DEFAULT true,
72
-
"authorId"INTEGERNOT NULL,
73
-
74
-
PRIMARY KEY ("id")
75
-
);
76
-
77
-
-- AddForeignKey
78
-
ALTERTABLE"Post" ADD FOREIGN KEY("authorId")REFERENCES"User"("id") ON DELETE CASCADEONUPDATE CASCADE;
79
-
```
73
+
:::
80
74
81
-
</cmdResult>
75
+
For Prisma 7, be sure to have a `prisma.config.ts` in the root of your project:
82
76
83
-
> **Note**: If you do not provide a `--name`, Prisma CLI will prompt you for a name.
77
+
```ts file=prisma.config.ts showLineNumbers
78
+
import'dotenv/config'
79
+
import { defineConfig, env } from"prisma/config";
80
+
exportdefaultdefineConfig({
81
+
schema: "prisma/schema.prisma",
82
+
migrations: {
83
+
path: "prisma/migrations",
84
+
},
85
+
datasource: {
86
+
url: env("DATABASE_URL"),
87
+
},
88
+
});
89
+
```
84
90
85
-
</CodeWithResult>
91
+
1. Create the first migration:
86
92
87
-
Your Prisma schema is now in sync with your database schema and you have initialized a migration history:
0 commit comments