leerob / next-saas-starter

Get started quickly with Next.js, Postgres, Stripe, and shadcn/ui.
https://next-saas-start.vercel.app
MIT License
5.63k stars 643 forks source link

pnpm db:seed is giving me a duplicate key value error of users_email_unique. #66

Open TommyJackson85 opened 1 month ago

TommyJackson85 commented 1 month ago

pnpm db:seed is giving me a duplicate key value error of users_email_unique. Any suggestions on what to change in the functions?

Seed process failed: PostgresError: duplicate key value violates unique constraint "users_email_unique" at ErrorResponse (/Users/thomasjackson/Desktop/venginez-templates/next-saas-starter/node_modules/.pnpm/postgres@3.4.4/node_modules/postgres/cjs/src/connection.js:788:26) at handle (/Users/thomasjackson/Desktop/venginez-templates/next-saas-starter/node_modules/.pnpm/postgres@3.4.4/node_modules/postgres/cjs/src/connection.js:474:6) at TLSSocket.data (/Users/thomasjackson/Desktop/venginez-templates/next-saas-starter/node_modules/.pnpm/postgres@3.4.4/node_modules/postgres/cjs/src/connection.js:315:9) at TLSSocket.emit (node:events:518:28) at addChunk (node:internal/streams/readable:559:12) at readableAddChunkPushByteMode (node:internal/streams/readable:510:3) at Readable.push (node:internal/streams/readable:390:5) at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) { severity_local: 'ERROR', severity: 'ERROR', code: '23505', detail: 'Key (email)=(test@test.com) already exists.', schema_name: 'public', table_name: 'users', constraint_name: 'users_email_unique', file: 'nbtinsert.c', line: '666', routine: '_bt_check_unique'

leerob commented 1 month ago

Have you already ran the script? You could use db:studio to view the contents and then delete that user.

TommyJackson85 commented 1 month ago

ill try db studio

TommyJackson85 commented 1 month ago

I just checked and theres one user of test@test.com email. so I don't see why there's an issue with it. i am afraid to delete it because I want to use that user for testing in general. In an attempt to delete it too I am getting this error 'update or delete on table "users" violates foreign key constraint "activity_logs_user_id_users_id_fk" on table "activity_logs"' and its asking me to report it drizzle studios github.

TommyJackson85 commented 1 month ago

is it possible theres a cookies related issues with this? can I check my database by the terminal to get more accurate info? any help would be great