File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,19 +59,8 @@ Open `.env` and configure the following:
5959
6060### 4. Database Setup
6161
62- Initialize your SQLite database and run migrations.
63-
64- ``` bash
65- pnpm dlx prisma migrate dev --name init
66- ```
67-
68- Generate the Prisma client
69-
70- ``` bash
71- pnpm dlx prisma generate
72- ```
73-
74- To reset the database and run the seed script:
62+ Initialize your SQLite database and run migrations. You will need to run this command anytime you need to change or create a database.
63+ If there are any migrations that need to be run, the command will ask for a name for the migration. You can simply hit enter, or name your migration.
7564
7665``` bash
7766pnpm prisma:reset
@@ -90,7 +79,7 @@ Your application will be available at `http://localhost:3000`. This command also
9079Login requires an email address that already exists in the database.
9180
9281- ** Option A: Use the seeded user**
93- Go to ` /auth ` and log in with ` alice@a .com` .
82+ Go to ` /auth ` and log in with ` email@example .com` .
9483- ** Option B: Use your own email**
9584 Update ` prisma/seed.ts ` with your email, then run ` pnpm prisma:reset ` to re-seed.
9685
Original file line number Diff line number Diff line change 88 "generate" : " nuxt generate" ,
99 "preview" : " nuxt preview" ,
1010 "postinstall" : " nuxt prepare" ,
11- "prisma:reset" : " prisma migrate reset -f && prisma db seed"
11+ "prisma:reset" : " prisma migrate reset -f && prisma migrate dev && prisma generate && prisma db seed"
1212 },
1313 "dependencies" : {
1414 "@nuxt/image" : " 2.0.0" ,
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ datasource db {
88}
99
1010model User {
11- id String @id
11+ id String @id @default ( uuid () )
1212 name String
1313 email String
1414 emailVerified Boolean @default (false )
@@ -23,7 +23,7 @@ model User {
2323}
2424
2525model Session {
26- id String @id
26+ id String @id @default ( uuid () )
2727 expiresAt DateTime
2828 token String
2929 createdAt DateTime @default (now () )
@@ -39,7 +39,7 @@ model Session {
3939}
4040
4141model Account {
42- id String @id
42+ id String @id @default ( uuid () )
4343 accountId String
4444 providerId String
4545 userId String
@@ -59,7 +59,7 @@ model Account {
5959}
6060
6161model Verification {
62- id String @id
62+ id String @id @default ( uuid () )
6363 identifier String
6464 value String
6565 expiresAt DateTime
Original file line number Diff line number Diff line change 1- import { Param } from '@prisma/client/runtime/client'
21import { prisma } from '../server/utils/prisma'
32
43async function main ( ) {
54 console . log ( 'Start seeding...' )
65
7- // 1. Create a User with a Password (Local Auth)
6+ // Create a User
87 const user1 = await prisma . user . create ( {
98 data : {
10- id : 'user_01' ,
11- name : 'Alice Developer' ,
12- email : 'alice@a.com' ,
13- emailVerified : true ,
14- accounts : {
15- create : {
16- id : 'acc_01' ,
17- accountId : 'alice_local_id' ,
18- providerId : 'credential' , // Common for email/password
19- password : 'hashed_password_here' , // In a real app, hash this!
20- } ,
21- } ,
22- } ,
9+ name : "Sample Name" , // modify this fit your needs
10+ email : "email@example.com"
11+ }
2312 } )
2413
25- // 2. Create a User with an OAuth Account (e.g., Google)
26- const user2 = await prisma . user . create ( {
27- data : {
28- id : 'user_02' ,
29- name : 'Bob Tester' ,
30- email : 'bob@b.com' ,
31- emailVerified : true ,
32- accounts : {
33- create : {
34- id : 'acc_02' ,
35- accountId : 'bob_google_id' ,
36- providerId : 'google' ,
37- accessToken : 'mock_access_token' ,
38- } ,
39- } ,
40- } ,
41- } )
42-
43- console . log ( { user1, user2 } )
14+ console . log ( { user1 } )
4415 console . log ( 'Seeding finished.' )
4516}
17+ // You can seed other models in your db as well depending on project needs
4618
4719main ( )
4820 . then ( async ( ) => {
You can’t perform that action at this time.
0 commit comments