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: www/docs/schemas/adapters.md
+16-6Lines changed: 16 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,13 +55,13 @@ However, it should not be enabled against production databases as it may cause d
55
55
56
56
## Prisma Adapter
57
57
58
-
You can also use NextAuth.js with [Prisma](https://www.prisma.io/docs/).
58
+
You can also use NextAuth.js with the experimental adapter for [Prisma 2](https://www.prisma.io/docs/).
59
59
60
60
To use this adapter, you need to install Prisma Client and Prisma CLI:
61
61
62
62
```
63
-
npm i @prisma/client
64
-
npm add -D @prisma/cli
63
+
npm install @prisma/client
64
+
npm install prisma --save-dev
65
65
```
66
66
67
67
Configure your NextAuth.js to use the Prisma adapter:
@@ -91,7 +91,7 @@ While Prisma includes an experimental feature in the migration command that is a
91
91
92
92
### Prisma Schema
93
93
94
-
Create a `schema.prisma` file similar to this one:
94
+
Create a schema file in `prisma/schema.prisma` similar to this one:
95
95
96
96
```json title="schema.prisma"
97
97
generator client {
@@ -179,12 +179,22 @@ datasource db {
179
179
180
180
### Generate Client
181
181
182
-
Once you have saved your schema, you can run the Prisma CLI to generate the Prisma Client:
182
+
Once you have saved your schema, use the Prisma CLI to generate the Prisma Client:
183
183
184
184
```
185
-
npx @prisma/cli generate
185
+
npx prisma generate
186
186
```
187
187
188
+
To configure you database to use the new schema (i.e. create tables and columns) use the `primsa migrate` command:
189
+
190
+
```
191
+
npx prisma migrate dev --preview-feature
192
+
```
193
+
194
+
To generate a schema in this way with the above example code, you will need to specify your datbase connection string in the environment variable `DATABASE_URL`. You can do this by setting it in a `.env` file at the root of your project.
195
+
196
+
As this feature is experimental in Prisma, it is behind a feature flag. You should check your database schema manually after using this option. See the [Prisma documentation](https://www.prisma.io/docs/) for information on how to use `prisma migrate`.
197
+
188
198
### Custom Models
189
199
190
200
You can add properties to the schema and map them to any database column names you wish, but you should not change the base properties or types defined in the example schema.
0 commit comments