-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[강대원] sprint7 #20
Open
Daewony
wants to merge
12
commits into
codeit-sprint-fullstack:express-강대원
Choose a base branch
from
Daewony:express-강대원-sprint7
base: express-강대원
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "express-\uAC15\uB300\uC6D0-sprint7"
Open
[강대원] sprint7 #20
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fd22023
chore: prisma 설치
Daewony dc445e4
feat: Article 스키마 추가
Daewony bc500b8
fix: product 삭제 요청 URL 경로 수정
Daewony bb49a14
test: Article의 CRUD 요청 테스트
Daewony 10ea567
refactor: asyncHandler & prismaClient 파일 재활용
Daewony bb11644
feat: Article 관련 api 추가
Daewony abb5c43
fix: 몽구스 스키마 이름 수정
Daewony 2891ff3
feat: 중고마켓 & 자유게시판 댓글 스키마 구성 추가
Daewony acceeef
feat: comment 마이그레이션 추가
Daewony f252c7d
fix: 몽구스 스키마 이름 변경
Daewony 9ddb3e7
fix: comment 스키마 이름 변경
Daewony 459c930
feat: ArticleComment api 관련 추가
Daewony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
prisma/migrations/20241110130539_add_article/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- CreateTable | ||
CREATE TABLE "Article" ( | ||
"id" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "Article_pkey" PRIMARY KEY ("id") | ||
); |
19 changes: 19 additions & 0 deletions
19
prisma/migrations/20241110164333_add_market_board_comment/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- CreateTable | ||
CREATE TABLE "MarketComment" ( | ||
"id" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "MarketComment_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "BoardComment" ( | ||
"id" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "BoardComment_pkey" PRIMARY KEY ("id") | ||
); |
47 changes: 47 additions & 0 deletions
47
prisma/migrations/20241112142438_add_comment_schema/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Warnings: | ||
|
||
- Added the required column `articleId` to the `BoardComment` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `userId` to the `BoardComment` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `articleId` to the `MarketComment` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `userId` to the `MarketComment` table without a default value. This is not possible if the table is not empty. | ||
|
||
*/ | ||
-- AlterTable | ||
ALTER TABLE "BoardComment" ADD COLUMN "articleId" TEXT NOT NULL, | ||
ADD COLUMN "userId" TEXT NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "MarketComment" ADD COLUMN "articleId" TEXT NOT NULL, | ||
ADD COLUMN "userId" TEXT NOT NULL; | ||
|
||
-- CreateTable | ||
CREATE TABLE "BoardArticle" ( | ||
"id" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "BoardArticle_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"nickname" TEXT NOT NULL, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "BoardComment" ADD CONSTRAINT "BoardComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "BoardComment" ADD CONSTRAINT "BoardComment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "BoardArticle"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
62 changes: 62 additions & 0 deletions
62
prisma/migrations/20241112150723_fix_comment/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Warnings: | ||
|
||
- You are about to drop the `BoardArticle` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `BoardComment` table. If the table is not empty, all the data it contains will be lost. | ||
|
||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "BoardComment" DROP CONSTRAINT "BoardComment_articleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "BoardComment" DROP CONSTRAINT "BoardComment_userId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "MarketComment" DROP CONSTRAINT "MarketComment_articleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "MarketComment" DROP CONSTRAINT "MarketComment_userId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "MarketComment" ALTER COLUMN "userId" DROP NOT NULL; | ||
|
||
-- DropTable | ||
DROP TABLE "BoardArticle"; | ||
|
||
-- DropTable | ||
DROP TABLE "BoardComment"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "MarketArticle" ( | ||
"id" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "MarketArticle_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ArticleComment" ( | ||
"id" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"userId" TEXT, | ||
"articleId" TEXT NOT NULL DEFAULT 'default', | ||
|
||
CONSTRAINT "ArticleComment_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleComment" ADD CONSTRAINT "ArticleComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleComment" ADD CONSTRAINT "ArticleComment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE SET DEFAULT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "MarketArticle"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
18 changes: 18 additions & 0 deletions
18
prisma/migrations/20241112151009_fix_comment/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
Warnings: | ||
|
||
- Made the column `userId` on table `ArticleComment` required. This step will fail if there are existing NULL values in that column. | ||
- Made the column `userId` on table `MarketComment` required. This step will fail if there are existing NULL values in that column. | ||
|
||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "MarketComment" DROP CONSTRAINT "MarketComment_userId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ArticleComment" ALTER COLUMN "userId" SET NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "MarketComment" ALTER COLUMN "userId" SET NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
26 changes: 26 additions & 0 deletions
26
prisma/migrations/20241112153016_fix_on_delete/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- DropForeignKey | ||
ALTER TABLE "ArticleComment" DROP CONSTRAINT "ArticleComment_articleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ArticleComment" DROP CONSTRAINT "ArticleComment_userId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "MarketComment" DROP CONSTRAINT "MarketComment_articleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "MarketComment" DROP CONSTRAINT "MarketComment_userId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ArticleComment" ALTER COLUMN "articleId" DROP DEFAULT; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleComment" ADD CONSTRAINT "ArticleComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleComment" ADD CONSTRAINT "ArticleComment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MarketComment" ADD CONSTRAINT "MarketComment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "MarketArticle"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? | ||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
model Article { | ||
id String @id @default(uuid()) | ||
title String | ||
content String | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
|
||
ArticleComment ArticleComment[] | ||
} | ||
|
||
model MarketArticle { | ||
id String @id @default(uuid()) | ||
title String | ||
content String | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
|
||
MarketComment MarketComment[] | ||
} | ||
|
||
|
||
model User { | ||
id String @id @default(uuid()) | ||
nickname String | ||
|
||
ArticleComment ArticleComment[] | ||
MarketComment MarketComment[] | ||
} | ||
|
||
model ArticleComment { | ||
id String @id @default(uuid()) | ||
content String | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
|
||
user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
userId String | ||
|
||
|
||
article Article @relation(fields: [articleId], references: [id], onDelete: Cascade) | ||
articleId String | ||
} | ||
|
||
|
||
model MarketComment { | ||
id String @id @default(uuid()) | ||
content String | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
|
||
user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
userId String | ||
|
||
marketArticle MarketArticle @relation(fields: [articleId], references: [id], onDelete: Cascade) | ||
articleId String | ||
} | ||
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
모델을 잘 구성해주신것 같아요. 테스트하실때 필요한 시딩이 필요할 수도 있을것 같아요