Skip to content

Commit 534f216

Browse files
committed
refactor: drop PayloadCMS legacy traces and consolidate DB SSL handling
- Delete one-shot `scripts/migrate-payload-to-prisma.ts` and the SSL-wrapping `run-prisma-migrate-*.mjs` runners; `db:migrate` and `db:migrate:deploy` now invoke `prisma migrate` directly. - Introduce `src/utils/database-url.ts#withDatabaseSslParams` that auto-appends `sslmode=require&uselibpqcompat=true` for `*.rds.amazonaws.com` hosts, and use it from both `src/utils/prisma.ts` and `prisma.config.ts` to keep runtime and migrations aligned. - Remove `PAYLOAD_*` env vars (`PAYLOAD_DATABASE_URL`, `PAYLOAD_DATABASE_SSL_REJECT_UNAUTHORIZED`, `PAYLOAD_S3_BASE_URL`, `PAYLOAD_S3_SOURCE_BUCKET`) and rename `PAYLOAD_S3_TARGET_BUCKET` -> `S3_BUCKET` across source, Dockerfile, GitHub Actions CD secrets, and `.env` / `.env.example`. - Drop direct `pg` / `@types/pg` deps (still installed transitively via `@prisma/adapter-pg`). - Scrub remaining Payload references from `README.md`, `AGENTS.md`, and `src/app/AGENTS.md`; drop the obsolete `DATABASE_SSL_REJECT_UNAUTHORIZED` override note. - Apply `prettier:write` across the repo (admin dashboard/actions, info pages, footer, scrolling logos, cms util, CI workflow).
1 parent 7976864 commit 534f216

26 files changed

Lines changed: 4755 additions & 2575 deletions

.env.example

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
DATABASE_URL=postgres://user:password@url:port/schema
2-
DATABASE_SSL_REJECT_UNAUTHORIZED=false
3-
PAYLOAD_DATABASE_URL=postgres://user:password@old-payload-url:port/schema
4-
PAYLOAD_DATABASE_SSL_REJECT_UNAUTHORIZED=false
5-
PAYLOAD_S3_BASE_URL=https://stdev-kr.s3.ap-northeast-2.amazonaws.com
6-
PAYLOAD_S3_SOURCE_BUCKET=stdev-kr
7-
PAYLOAD_S3_TARGET_BUCKET=stdev-kr
2+
S3_BUCKET=stdev-kr
83
AWS_REGION=ap-northeast-2
94
AWS_ACCESS_KEY=example
105
AWS_SECRET_KEY=example

.github/workflows/cd.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
if: github.event_name != 'pull_request'
4242
env:
4343
DATABASE_URL: ${{ secrets.DATABASE_URL }}
44-
DATABASE_SSL_REJECT_UNAUTHORIZED: ${{ secrets.DATABASE_SSL_REJECT_UNAUTHORIZED }}
4544
run: pnpm db:migrate:deploy
4645

4746
- name: Install cosign
@@ -77,8 +76,7 @@ jobs:
7776
"NEXT_PUBLIC_GTM_ID=${{ secrets.NEXT_PUBLIC_GTM_ID }}"
7877
"NEXT_PUBLIC_GA_ID=${{ secrets.NEXT_PUBLIC_GA_ID }}"
7978
"DATABASE_URL=${{ secrets.DATABASE_URL }}"
80-
"PAYLOAD_S3_BASE_URL=${{ secrets.PAYLOAD_S3_BASE_URL }}"
81-
"PAYLOAD_S3_TARGET_BUCKET=${{ secrets.PAYLOAD_S3_TARGET_BUCKET }}"
79+
"S3_BUCKET=${{ secrets.S3_BUCKET }}"
8280
"AWS_REGION=${{ secrets.AWS_REGION }}"
8381
"BETTER_AUTH_SECRET=${{ secrets.BETTER_AUTH_SECRET }}"
8482
"BETTER_AUTH_URL=${{ secrets.BETTER_AUTH_URL }}"

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88

99
env:
10-
NODE_VERSION: "24"
10+
NODE_VERSION: '24'
1111

1212
jobs:
1313
build:
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/setup-node@v4
2525
with:
2626
node-version: ${{ env.NODE_VERSION }}
27-
cache: "pnpm"
27+
cache: 'pnpm'
2828

2929
- name: Copy example env file
3030
run: cp .env.example .env
@@ -47,7 +47,7 @@ jobs:
4747
uses: actions/setup-node@v4
4848
with:
4949
node-version: ${{ env.NODE_VERSION }}
50-
cache: "pnpm"
50+
cache: 'pnpm'
5151

5252
- name: Install dependencies
5353
run: pnpm install --frozen-lockfile

AGENTS.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ STDev Corp. (사단법인 에스티데브) Korean nonprofit homepage. Next.js 16
1010
stdev/
1111
├── prisma/schema.prisma # CMS/auth data model
1212
├── prisma.config.ts # Prisma config; reads DATABASE_URL
13-
├── scripts/ # Data migration utilities
1413
├── src/
1514
│ ├── app/ # (stdev) public site, (cms) admin, api/auth
1615
│ ├── components/ # UI building blocks
@@ -28,7 +27,6 @@ stdev/
2827
| Prisma client | `src/utils/prisma.ts` | Reuses one client during dev hot reload |
2928
| Auth config | `src/utils/auth.ts` + `src/utils/admin-auth.ts` + `src/app/api/auth/[...all]/route.ts` | Google-only better-auth with Prisma adapter |
3029
| Admin UI | `src/app/(cms)/admin/**` | DIY CMS forms protected by better-auth |
31-
| Payload migration | `scripts/migrate-payload-to-prisma.ts` | Dry-run by default; `--write` persists rows |
3230
| Add a public page/route | `src/app/(stdev)/<path>/page.tsx` | Also update `src/utils/menus.ts` and `src/utils/links.ts` |
3331
| Shared layout chrome | `src/components/layout/` | `basic-layout`, `left-menu-layout`, `navbar`, `footer` |
3432
| Markdown rendering | `src/components/markdown/markdown-view.tsx` | Chakra-mapped react-markdown + remark-gfm |
@@ -46,7 +44,6 @@ stdev/
4644

4745
## ANTI-PATTERNS
4846

49-
- Do not reintroduce Payload CMS packages, generated admin routes, or `payload.config.ts`.
5047
- Do not edit generated Prisma client output in `node_modules`; change `prisma/schema.prisma` and regenerate.
5148
- Do not add semicolons.
5249
- Do not statically render `(stdev)`.
@@ -64,13 +61,11 @@ pnpm prettier:check # CI-style check
6461
pnpm db:generate # Generate Prisma client
6562
pnpm db:migrate # Local schema migration
6663
pnpm db:migrate:deploy # Production migration deploy
67-
pnpm migrate:payload # Dry-run old Payload RDS row counts
68-
pnpm migrate:payload -- --write # Copy old Payload rows into Prisma tables
6964
```
7065

7166
## NOTES
7267

7368
- No test suite exists. CI runs build + lint.
7469
- Docker prod port is 1000.
7570
- Existing S3 object URLs are preserved as CMS asset URLs; remote host is `stdev-kr.s3.ap-northeast-2.amazonaws.com`.
76-
- `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, and `DATABASE_URL` are required for the CMS/auth stack. Set `DATABASE_SSL_REJECT_UNAUTHORIZED=false` only when your managed Postgres requires unverified/self-signed TLS.
71+
- `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, and `DATABASE_URL` are required for the CMS/auth stack.

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ RUN --mount=type=secret,id=NEXT_PUBLIC_CHANNEL_PLUGIN_KEY,env=NEXT_PUBLIC_CHANNE
2222
--mount=type=secret,id=NEXT_PUBLIC_GTM_ID,env=NEXT_PUBLIC_GTM_ID \
2323
--mount=type=secret,id=NEXT_PUBLIC_GA_ID,env=NEXT_PUBLIC_GA_ID \
2424
--mount=type=secret,id=DATABASE_URL,env=DATABASE_URL \
25-
--mount=type=secret,id=PAYLOAD_S3_BASE_URL,env=PAYLOAD_S3_BASE_URL \
26-
--mount=type=secret,id=PAYLOAD_S3_TARGET_BUCKET,env=PAYLOAD_S3_TARGET_BUCKET \
25+
--mount=type=secret,id=S3_BUCKET,env=S3_BUCKET \
2726
--mount=type=secret,id=AWS_REGION,env=AWS_REGION \
2827
--mount=type=secret,id=BETTER_AUTH_SECRET,env=BETTER_AUTH_SECRET \
2928
--mount=type=secret,id=BETTER_AUTH_URL,env=BETTER_AUTH_URL \

README.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ services:
4545
restart: always
4646
environment:
4747
DATABASE_URL: postgres://user:password@url:port/schema
48-
DATABASE_SSL_REJECT_UNAUTHORIZED: 'false'
4948
BETTER_AUTH_SECRET: example
5049
BETTER_AUTH_URL: https://www.stdev.kr
5150
GOOGLE_CLIENT_ID: example.apps.googleusercontent.com
5251
GOOGLE_CLIENT_SECRET: example
5352
AWS_REGION: ap-northeast-2
5453
AWS_ACCESS_KEY: example
5554
AWS_SECRET_KEY: example
56-
PAYLOAD_S3_TARGET_BUCKET: stdev-kr
55+
S3_BUCKET: stdev-kr
5756
```
5857
5958
컨테이너를 올리기 전에 Prisma 스키마 마이그레이션을 먼저 적용합니다.
@@ -69,19 +68,3 @@ docker compose up -d
6968
```
7069

7170
Port `1000` 번에 Reverse Proxy를 붙입니다.
72-
73-
## CMS migration
74-
75-
Payload CMS has been replaced by the Prisma-backed DIY CMS at `/admin`. Admin access requires a Google-connected account whose email ends with `@stdev.kr`.
76-
77-
```bash
78-
pnpm db:generate
79-
pnpm db:migrate
80-
pnpm migrate:payload # dry-run: prints detected Payload rows
81-
pnpm migrate:payload -- --write
82-
pnpm migrate:payload -- --write --copy-s3
83-
```
84-
85-
Set `PAYLOAD_DATABASE_URL` when the old Payload RDS database is separate from the new `DATABASE_URL`. The migration keeps existing S3 object URLs from the old RDS rows, or reconstructs them from `PAYLOAD_S3_BASE_URL`, `prefix`, and `filename` when Payload stored only upload metadata. Add `--copy-s3` to copy objects from `PAYLOAD_S3_SOURCE_BUCKET` to `PAYLOAD_S3_TARGET_BUCKET` with the configured `AWS_REGION`, `AWS_ACCESS_KEY`, and `AWS_SECRET_KEY` instead of only reusing existing URLs.
86-
87-
If your managed Postgres uses self-signed or unverified TLS, set `DATABASE_SSL_REJECT_UNAUTHORIZED=false` and `PAYLOAD_DATABASE_SSL_REJECT_UNAUTHORIZED=false`. Otherwise leave them unset to keep certificate verification enabled.

next.config.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import type { NextConfig } from 'next'
22

33
const s3Hosts = new Set([
44
'stdev-kr.s3.ap-northeast-2.amazonaws.com',
5-
process.env.PAYLOAD_S3_BASE_URL
6-
? new URL(process.env.PAYLOAD_S3_BASE_URL).hostname
7-
: null,
8-
process.env.PAYLOAD_S3_TARGET_BUCKET
9-
? `${process.env.PAYLOAD_S3_TARGET_BUCKET}.s3.${process.env.AWS_REGION ?? 'ap-northeast-2'}.amazonaws.com`
5+
process.env.S3_BUCKET
6+
? `${process.env.S3_BUCKET}.s3.${process.env.AWS_REGION ?? 'ap-northeast-2'}.amazonaws.com`
107
: null,
118
])
129

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
"prettier:write": "prettier --write .",
1212
"prettier:check": "prettier --check .",
1313
"db:generate": "prisma generate",
14-
"db:migrate": "node scripts/run-prisma-migrate-dev.mjs",
15-
"db:migrate:deploy": "node scripts/run-prisma-migrate-deploy.mjs",
16-
"db:studio": "prisma studio",
17-
"migrate:payload": "tsx scripts/migrate-payload-to-prisma.ts"
14+
"db:migrate": "prisma migrate dev",
15+
"db:migrate:deploy": "prisma migrate deploy",
16+
"db:studio": "prisma studio"
1817
},
1918
"dependencies": {
2019
"@aws-sdk/client-s3": "^3.1042.0",
@@ -29,7 +28,6 @@
2928
"dayjs": "^1.11.20",
3029
"dotenv": "^17.4.2",
3130
"next": "16.2.4",
32-
"pg": "^8.20.0",
3331
"react": "^19.2.5",
3432
"react-dom": "^19.2.5",
3533
"react-markdown": "^10.1.0",
@@ -39,7 +37,6 @@
3937
},
4038
"devDependencies": {
4139
"@types/node": "^24.12.2",
42-
"@types/pg": "^8.20.0",
4340
"@types/react": "^19.2.14",
4441
"@types/react-dom": "^19.2.3",
4542
"eslint": "^9.39.4",

0 commit comments

Comments
 (0)