-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add prisma & basic settings * chore: add .env to gitignore * fix: add shadow database url in schema for solving migration issue * feat: add @prisma/client and db schema file path * chore: add migration files to gitignore * chore: add scripts for prisma * feat: add test api * feat: add docker compose & actions * fix: add checkout option & prod action * fix: add migration files * fix: remove edge option * feat: add edge test api * build(package): update nextjs * fix: add runtime option * fix: remove runtime option * docs(github): add pr template --------- Co-authored-by: Go Gwangseo <rufflain918@gmail.com>
- Loading branch information
1 parent
86df22c
commit 643de27
Showing
18 changed files
with
329 additions
and
134 deletions.
There are no files selected for viewing
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,15 @@ | ||
## Issue | ||
|
||
Resolves #(이슈 번호) | ||
|
||
## Description | ||
|
||
## Check List | ||
|
||
- [ ] PR 제목을 커밋 규칙에 맞게 작성 | ||
- [ ] 적절한 라벨 설정 | ||
- [ ] GitHub Projects에 연결 | ||
- [ ] 작업한 사람 모두를 Assign | ||
- [ ] Code Review 요청 | ||
- [ ] DB Schema를 바꾼 경우, DB Schema를 바꾸는 다른 PR이 없는지 확인 | ||
- [ ] `main` 브랜치의 최신 상태를 반영하고 있는지 확인 |
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
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,28 @@ | ||
name: 'DB Migration (Production)' | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/database/schema.prisma' | ||
|
||
jobs: | ||
migrate: | ||
runs-on: ubuntu-latest | ||
environment: Production | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Migrate | ||
run: yarn db:prod | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} |
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,27 @@ | ||
name: 'DB Migration' | ||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
paths: | ||
- 'src/database/schema.prisma' | ||
|
||
jobs: | ||
migrate: | ||
runs-on: ubuntu-latest | ||
environment: Preview | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Migrate | ||
run: yarn db:prod | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} |
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ yarn-error.log* | |
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
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
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
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,12 @@ | ||
services: | ||
postgres: | ||
image: postgres:15.1 | ||
ports: | ||
- '5466:5432' | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_PASSWORD: '' | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
volumes: | ||
db_data: |
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,12 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
/** | ||
* @see https://www.prisma.io/docs/guides/database/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices | ||
*/ | ||
const globalForPrisma = global as unknown as { prisma: PrismaClient }; | ||
|
||
export const prisma = globalForPrisma.prisma || new PrismaClient(); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
globalForPrisma.prisma = prisma; | ||
} |
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
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
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,8 @@ | ||
-- CreateTable | ||
CREATE TABLE "test" ( | ||
"id" SERIAL NOT NULL, | ||
"test" TEXT NOT NULL, | ||
"test2" TEXT NOT NULL, | ||
|
||
CONSTRAINT "test_pkey" PRIMARY KEY ("id") | ||
); |
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,14 @@ | ||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
model test { | ||
id Int @id @default(autoincrement()) | ||
test String | ||
test2 String | ||
} |
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 @@ | ||
import type { NextRequest } from 'next/server'; | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async function handler(req: NextRequest) { | ||
return new Response( | ||
JSON.stringify({ | ||
name: 'Jim Halpert', | ||
}), | ||
{ | ||
status: 200, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
}, | ||
); | ||
} |
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 |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import type { NextRequest } from 'next/server'; | ||
import { prisma } from '@/lib/prisma'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
export const config = { | ||
runtime: 'experimental-edge', | ||
}; | ||
|
||
export default function handler(req: NextRequest) { | ||
return new Response( | ||
JSON.stringify({ | ||
name: 'Jim Halpert', | ||
}), | ||
{ | ||
status: 200, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
export default async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse, | ||
) { | ||
const newTest = await prisma.test.create({ | ||
data: { | ||
test: '1234', | ||
test2: '5678', | ||
}, | ||
); | ||
}); | ||
|
||
res.status(200).json(newTest); | ||
} |
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
Oops, something went wrong.
643de27
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.
Successfully deployed to the following URLs:
web – ./
web-xi-liart.vercel.app
web-gdsc-ssu.vercel.app
web-git-main-gdsc-ssu.vercel.app