Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Kuldz/Users into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuldz committed Feb 18, 2022
2 parents 78cee01 + 0dd77b1 commit 8ef38e9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ The `pages/api` directory is mapped to `/api/*`. Files in this directory are tre

npx prisma migrate deploy

* create new user by running seed

npx prisma db seed

we use prisma.io as ORM read more https://www.prisma.io/docs/concepts

## Deploy on Vercel
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "users",
"private": true,

"scripts": {
"dev": "next dev",
"build": "next build",
Expand All @@ -15,6 +16,13 @@
"react": "^17.0.2",
"react-dom": "^17.0.2"
},


"version": "1.0.0",
"prisma": {
"seed": "node prisma/seed.js"
},

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.33.0",
"eslint": "^7.32.0",
Expand Down
5 changes: 0 additions & 5 deletions pages/api/hello.js

This file was deleted.

8 changes: 8 additions & 0 deletions prisma/migrations/20220218113151_unique_email/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[email]` on the table `User` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX `User_email_key` ON `User`(`email`);
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ datasource db {

model User {
id Int @id @default(autoincrement())
email String
email String @unique
password String
}
23 changes: 23 additions & 0 deletions prisma/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { PrismaClient } = require("@prisma/client")
const prisma = new PrismaClient()

async function main () {
await prisma.user.upsert({
where: { email: "[email protected]" },
update: {},
create: {
email: "[email protected]",
password: "qwe123"
}
})
console.log("success")
}

main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})

0 comments on commit 8ef38e9

Please sign in to comment.