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
Copy file name to clipboardExpand all lines: content/800-guides/060-migrate-from-drizzle.mdx
+44-11Lines changed: 44 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,11 +82,11 @@ The Prisma schema currently looks as follows:
82
82
83
83
datasource db {
84
84
provider = "postgresql"
85
-
url = env("DATABASE_URL")
86
85
}
87
86
88
87
generator client {
89
-
provider = "prisma-client-js"
88
+
provider = "prisma-client"
89
+
output = "./generated/prisma"
90
90
}
91
91
```
92
92
@@ -107,7 +107,6 @@ If you're not using PostgreSQL, you need to adjust the `provider` field on the `
107
107
```prisma file=schema.prisma showLineNumbers
108
108
datasource db {
109
109
provider = "postgresql"
110
-
url = env("DATABASE_URL")
111
110
}
112
111
```
113
112
@@ -118,7 +117,6 @@ datasource db {
118
117
```prisma file=schema.prisma showLineNumbers
119
118
datasource db {
120
119
provider = "mysql"
121
-
url = env("DATABASE_URL")
122
120
}
123
121
```
124
122
@@ -129,7 +127,6 @@ datasource db {
129
127
```prisma file=schema.prisma showLineNumbers
130
128
datasource db {
131
129
provider = "sqlserver"
132
-
url = env("DATABASE_URL")
133
130
}
134
131
```
135
132
@@ -140,7 +137,6 @@ datasource db {
140
137
```prisma file=schema.prisma showLineNumbers
141
138
datasource db {
142
139
provider = "sqlite"
143
-
url = env("DATABASE_URL")
144
140
}
145
141
```
146
142
@@ -150,7 +146,36 @@ datasource db {
150
146
151
147
Once that's done, you can configure your [database connection URL](/orm/reference/connection-urls) in the `.env` file. Drizzle and Prisma ORM use the same format for connection URLs, so your existing connection URL should work fine.
152
148
153
-
### 2.3. Introspect your database using Prisma ORM
149
+
### 2.3. Configure Prisma
150
+
151
+
Create a `prisma.config.ts` file in the root of your project with the following content:
152
+
153
+
```typescript file=prisma.config.ts
154
+
import'dotenv/config'
155
+
import { defineConfig, env } from'prisma/config';
156
+
157
+
exportdefaultdefineConfig({
158
+
schema: 'prisma/schema.prisma',
159
+
migrations: {
160
+
path: 'prisma/migrations',
161
+
},
162
+
datasource: {
163
+
url: env('DATABASE_URL'),
164
+
},
165
+
});
166
+
```
167
+
168
+
:::note
169
+
170
+
You'll need to install the `dotenv` package to load environment variables. If you haven't already, install it using your package manager:
171
+
172
+
```bash
173
+
npm install dotenv
174
+
```
175
+
176
+
:::
177
+
178
+
### 2.4. Introspect your database using Prisma ORM
154
179
155
180
With your connection URL in place, you can [introspect](/orm/prisma-schema/introspection) your database to generate your Prisma models:
156
181
@@ -170,7 +195,7 @@ model todo {
170
195
171
196
The generated Prisma model represents a database table. Prisma models are the foundation for your programmatic Prisma Client API which allows you to send queries to your database.
172
197
173
-
### 2.4. Create a baseline migration
198
+
### 2.5. Create a baseline migration
174
199
175
200
To continue using Prisma Migrate to evolve your database schema, you will need to [baseline your database](/orm/prisma-migrate/getting-started).
176
201
@@ -202,7 +227,7 @@ The command will mark `0_init` as applied by adding it to the `_prisma_migration
202
227
203
228
You now have a baseline for your current database schema. To make further changes to your database schema, you can update your Prisma schema and use `prisma migrate dev` to apply the changes to your database.
204
229
205
-
### 2.5. Adjust the Prisma schema (optional)
230
+
### 2.6. Adjust the Prisma schema (optional)
206
231
207
232
Models that are generated via introspection currently _exactly_ map to your database tables. In this section, you'll learn how you can adjust the naming of the Prisma models to adhere to [Prisma ORM's naming conventions](/orm/reference/prisma-schema-reference#naming-conventions).
208
233
@@ -254,9 +279,17 @@ touch db/prisma.ts
254
279
Now, instantiate `PrismaClient` and export it from the file so you can use it in your route handlers later:
Copy file name to clipboardExpand all lines: content/800-guides/070-cloudflare-d1.mdx
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,13 +53,12 @@ In your Prisma schema, set the `provider` of the `datasource` to `sqlite`. If yo
53
53
54
54
```prisma file=prisma/schema.prisma
55
55
generator client {
56
-
provider = "prisma-client-js"
56
+
provider = "prisma-client"
57
57
output = "../src/generated/prisma"
58
58
}
59
59
60
60
datasource db {
61
61
provider = "sqlite"
62
-
url = env("DATABASE_URL")
63
62
}
64
63
65
64
//add-start
@@ -179,7 +178,7 @@ CLOUDFLARE_D1_TOKEN="F8Cg..."
179
178
180
179
Ensure that you have a `prisma.config.ts` file set up in the root of your project with a [driver adapter](/orm/reference/prisma-config-reference#adapter-removed) defined.
0 commit comments