Skip to content

refactor: drop PayloadCMS legacy traces and consolidate DB SSL handling#18

Merged
sboh1214 merged 9 commits into
mainfrom
refactor@drop-payloadcms-legacy
May 12, 2026
Merged

refactor: drop PayloadCMS legacy traces and consolidate DB SSL handling#18
sboh1214 merged 9 commits into
mainfrom
refactor@drop-payloadcms-legacy

Conversation

@sboh1214
Copy link
Copy Markdown
Contributor

@sboh1214 sboh1214 commented May 12, 2026

요약

PayloadCMS 기반 CMS를 Prisma + better-auth DIY CMS로 전환한 뒤 남아있던 레거시 흔적을 정리하고, DB 연결/SSL 설정을 앱 런타임과 Prisma CLI가 일관되게 사용하도록 일원화합니다. 기능/디자인 변경은 없습니다.

주요 변경

1. PayloadCMS 레거시 제거

  • scripts/migrate-payload-to-prisma.ts 삭제 — 이미 완료된 1회성 마이그레이션 스크립트
  • scripts/ 폴더 전체 제거 — db:migrate / db:migrate:deploy가 Prisma CLI를 직접 호출하도록 변경
  • 환경변수 정리
    • 삭제: PAYLOAD_DATABASE_URL, PAYLOAD_DATABASE_SSL_REJECT_UNAUTHORIZED, PAYLOAD_S3_BASE_URL, PAYLOAD_S3_SOURCE_BUCKET
    • 이름 변경: PAYLOAD_S3_TARGET_BUCKETS3_BUCKET
  • 직접 의존성 pg, @types/pg 제거 (@prisma/adapter-pg가 transitive로 계속 제공)
  • README.md, AGENTS.md, src/app/AGENTS.md에서 Payload 관련 문구/anti-pattern 정리

2. DB 연결/SSL 일원화

  • src/utils/database-url.ts 신설 — withDatabaseSslParams(url) 헬퍼가 호스트가 *.rds.amazonaws.com일 때에 한해 sslmode=require&uselibpqcompat=true를 자동 추가
  • src/utils/prisma.tsprisma.config.ts 양쪽에서 동일한 헬퍼를 경유하므로 런타임과 migration이 동일한 SSL 정책을 사용
  • 기존 DATABASE_SSL_REJECT_UNAUTHORIZED 환경변수 및 관련 분기 제거
  • scripts/run-prisma-migrate-*.mjs shell wrapper 불필요해져 삭제

3. 배포 파이프라인 정리

  • Dockerfile: PAYLOAD_S3_BASE_URL secret mount 제거, PAYLOAD_S3_TARGET_BUCKETS3_BUCKET
  • .github/workflows/cd.yml: 빌드 secret 리스트에서 동일하게 정리, migrate 스텝의 DATABASE_SSL_REJECT_UNAUTHORIZED 전달 삭제
  • .env.example 스키마 축소

4. 코드 포맷 정리

  • 저장소 전체에 pnpm prettier:write 적용 (admin dashboard/actions, 정보 페이지, footer, scrolling-logos, utils/cms.ts, CI workflow)

병합 전 배포 체크리스트

  1. GitHub Actions → Settings → SecretsPAYLOAD_S3_BASE_URL, PAYLOAD_S3_TARGET_BUCKET, DATABASE_SSL_REJECT_UNAUTHORIZED 삭제하고 S3_BUCKET 추가
  2. Production docker-compose.ymlPAYLOAD_S3_TARGET_BUCKETS3_BUCKET 교체, DATABASE_SSL_REJECT_UNAUTHORIZED 라인 제거
  3. Production DATABASE_URL?sslmode=... 수동 파라미터 없이도 동작 (RDS 호스트면 withDatabaseSslParams가 자동 처리, 아니면 그대로 전달)

검증

  • pnpm build 통과 (전체 라우트 정상 빌드)
  • pnpm lint 통과 (경고 없음)
  • src/ LSP diagnostics 0 errors
  • 저장소 전체 grep -i payload 결과 0건

참고

  • 이 PR은 기존 브랜치 feat@add-contents-with-payloadrefactor@drop-payloadcms-legacy로 rename한 결과입니다. 구 원격 브랜치는 별도로 정리해주세요.

Summary by CodeRabbit

  • New Features

    • Added admin authentication with Google Sign-In for authorized users
    • Launched CMS dashboard to manage content: businesses, institutions, reports, articles, images, and files
    • Integrated AWS S3 for file and image storage
  • Documentation

    • Updated setup and deployment instructions with new environment requirements
  • Chores

    • Migrated backend infrastructure and authentication system
    • Updated database and deployment workflow configuration

sboh1214 added 6 commits May 6, 2026 02:35
정관, 개인정보처리방침, 이용약관, 총회/이사회
chore: add AGENTS.md
- 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).
coderabbitai[bot]

This comment was marked as outdated.

@stdev-corp stdev-corp deleted a comment from coderabbitai Bot May 12, 2026
@sboh1214 sboh1214 self-assigned this May 12, 2026
@sboh1214 sboh1214 added the enhancement New feature or request label May 12, 2026
sboh1214 added 2 commits May 12, 2026 15:06
CI copies `.env.example` to `.env` before running `pnpm build`, but the
previous placeholder `postgres://user:password@url:port/schema` is not a
valid URL (WHATWG URL parser rejects non-numeric `port`), causing
`prisma generate` to crash while loading `prisma.config.ts` via
`withDatabaseSslParams` -> `new URL(...)`.

- Use a parseable placeholder in `.env.example` (`host:5432`).
- Wrap `new URL(...)` in `withDatabaseSslParams` with try/catch so any
  unparseable DATABASE_URL is returned as-is instead of breaking the
  Prisma config load.
Prisma 7's `prisma.config.ts` resolves `env('DATABASE_URL')` eagerly at
config load time, so `prisma generate` aborts with PrismaConfigEnvError
when the env var is missing -- e.g. during the Docker build stage of
the CD workflow where the DATABASE_URL secret is sourced per-RUN and
is absent (or empty) on the very first evaluation of the config.

Switch to a direct `process.env.DATABASE_URL` read with a non-empty
placeholder fallback so config loading and `prisma generate` are
decoupled from whether the runtime secret is wired up. Real migrations
and runtime use still require a proper DATABASE_URL, and will surface a
clear connection error if the placeholder is ever reached.
@sboh1214
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11c6a1e51b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/cd.yml Outdated
Comment on lines +40 to +44
- name: Deploy Prisma migrations
if: github.event_name != 'pull_request'
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: pnpm db:migrate:deploy
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Run Prisma migrations only after build/push succeeds

In .github/workflows/cd.yml the production migration step runs before the Docker build/push steps, so a failed build, registry login, or image push can leave the database schema advanced while production is still running the previous image. This creates a real rollout hazard for non-backward-compatible migrations (old app against new schema) and can require manual rollback/recovery; move migration execution to a post-build deploy phase that only runs after the artifact is successfully built and published.

Useful? React with 👍 / 👎.

@sboh1214 sboh1214 enabled auto-merge May 12, 2026 06:37
@sboh1214 sboh1214 merged commit 971182d into main May 12, 2026
3 checks passed
@sboh1214 sboh1214 deleted the refactor@drop-payloadcms-legacy branch May 12, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant