Skip to content

Commit 6281592

Browse files
committed
feat: add password field for user table
1 parent 03c3717 commit 6281592

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `image` on the `Tags` table. All the data in the column will be lost.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Tags" DROP COLUMN "image";
9+
10+
-- AlterTable
11+
ALTER TABLE "User" ADD COLUMN "password" TEXT;

packages/database/prisma/schema.prisma

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ model Post {
8282
comments Comment[]
8383
parentOf ParentPost[] @relation("parentPost")
8484
parent ParentPost[] @relation("post")
85-
Image Image? @relation(fields: [imageId], references: [id])
85+
image Image? @relation(fields: [imageId], references: [id])
8686
imageId String?
8787
}
8888

@@ -150,6 +150,7 @@ model User {
150150
email String? @unique
151151
emailVerified DateTime?
152152
image String?
153+
password String?
153154
154155
userType UserType @default(AUTHOR)
155156
@@ -179,7 +180,7 @@ model User {
179180
followings Follower[] @relation("following")
180181
comment Comment[]
181182
commentOnUser CommentOnUser[]
182-
Image Image[]
183+
images Image[]
183184
}
184185

185186
model Follower {
@@ -213,8 +214,7 @@ model Tags {
213214
createdAt DateTime @default(now())
214215
updatedAt DateTime @updatedAt
215216
216-
type TagType @default(TAG)
217-
image String?
217+
type TagType @default(TAG)
218218
219219
totalPost Int @default(0)
220220
totalView Int @default(0)
@@ -228,7 +228,7 @@ model Tags {
228228
count Int @default(0)
229229
230230
tagOnPost TagOnPost[]
231-
Image Image? @relation(fields: [imageId], references: [id])
231+
image Image? @relation(fields: [imageId], references: [id])
232232
imageId String?
233233
}
234234

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { PrismaClient } from "@prisma/client"
2+
3+
const prisma = new PrismaClient()
4+
5+
async function main() {
6+
const user = await prisma.user.create({
7+
data: {
8+
name: "John Doe",
9+
email: "john.doe@example.com",
10+
// password: "password",
11+
},
12+
})
13+
}
14+
15+
main().then(() => {
16+
console.log("User created successfully")
17+
})

packages/database/src/posts/selects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const postSelect = {
1010
postStatus: true,
1111
totalLike: true,
1212
totalFollow: true,
13-
Image: {
13+
image: {
1414
select: {
1515
id: true,
1616
url: true,

packages/database/src/tags/selects.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ export const tagListSelect = {
55
name: true,
66
slug: true,
77
description: true,
8-
image: true,
8+
image: {
9+
select: {
10+
id: true,
11+
url: true,
12+
},
13+
},
914
type: true,
1015
totalFollowers: true,
1116
updatedAt: true,

0 commit comments

Comments
 (0)