Skip to content

feat(scripts): just seed-from-prod 으로 PRD→dev 시드 자동화 (#371 follow-up)#377

Merged
thxforall merged 3 commits into
devfrom
feature/seed-from-prod-automation
Apr 30, 2026
Merged

feat(scripts): just seed-from-prod 으로 PRD→dev 시드 자동화 (#371 follow-up)#377
thxforall merged 3 commits into
devfrom
feature/seed-from-prod-automation

Conversation

@thxforall
Copy link
Copy Markdown
Contributor

Summary

  • scripts/seed-from-prod.sh 신규 — PRD→dev 시드 단일 명령
  • Justfile seed-from-prod target 추가
  • 9단계 수동 절차 → 1줄 (just seed-from-prod)

Spec 의 옵션 #5 — part of #371.

배경

2026-04-30 PRD→dev 시드 작업이 9 단계 수동 절차로 진행됐음:

  1. PRD URL export
  2. (옵션) 사이즈 확인
  3. pg_dump auth + public
  4. supabase db reset --no-seed
  5. system-seed row 삭제 (categories code='system' + subcategories code='uncategorized')
  6. (post_magazines.status='failed' drift 정합화 #372 미적용 PRD 면) constraint 임시 alter
  7. import auth → public
  8. row count 검증
  9. cleanup (/tmp 파일 + env unset)

매번 반복 수행 비효율 + 단계 빠뜨릴 위험. 재사용 가능하게 패키징.

사용법

# 본인 셸에서 (절대 채팅 아님)
export PRD_DB_URL='postgresql://postgres.<ref>:<password>@<region>.pooler.supabase.com:6543/postgres'

just seed-from-prod

PRD_DB_URL 미설정 시 fail-fast + Dashboard 안내 메시지 출력.

안전 가드

  • Secret 노출 방지: PRD_DB_URL env 만 사용. 명령어 인라인 금지. 출력 메시지에서도 비밀번호 로테이션을 명시 안내.
  • Prerequisite 사전 체크: pg_dump, psql, docker, supabase 누락 시 즉시 fail.
  • 로컬 컨테이너 확인: supabase_db_* 컨테이너 미기동 시 안내.
  • Tmp 파일 격리: /tmp/prd-{auth,public}.$$.sql (PID 접미사). trap cleanup EXIT 로 성공/실패 모두에서 자동 삭제.
  • Interactive confirm: 'yes' 입력 필수. 실수로 dev DB 날리는 것 방지.
  • post_magazines.status='failed' drift 정합화 #372 drift 안내: 마이그레이션 미적용 PRD 라면 import 가 깨질 수 있음을 종료 메시지에 명시.

검증

  • bash -n syntax OK
  • PRD_DB_URL 미설정 시 fail-fast 동작 + helpful 메시지
  • just seed-from-prod target 정상 호출

검증 미완 (사용자/CI)

  • 실제 PRD URL export 후 end-to-end 시드 정상 동작 — PRD 접근 권한 + 비밀번호 로테이션 후
  • 다른 OS (Linux) 에서 동작 검증

관련

Test plan

  • 다른 개발자가 본인 셸에서 export PRD_DB_URL + just seed-from-prod 실행 시 정상 종료
  • bash -n 통과 (이미 확인)
  • (옵션) shellcheck 통과 — CI 추가 검토

🤖 Generated with Claude Code

thxforall and others added 2 commits April 30, 2026 15:02
PRD→dev 시드 작업 중 발견된 post_magazines.status='failed' drift를
계기로, dev/prod/assets 3 영역과 Supabase CLI / SeaORM / TS 상수
3종 사실상 SOT 의 운영 모델 정리 로드맵을 4단계로 분해.

GitHub 이슈 등록:
- #371 DB 운영 모델 SOT 문서화 (P0)
- #372 post_magazines.status='failed' drift 정합화 (P1)
- #373 drift 검증 CI 게이트 (P2)
- #374 [Epic] SeaORM ↔ Supabase 마이그레이션 통합 B.3 (P3)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
이전에 PRD→dev 시드는 9 단계 수동 절차로 (export, dump auth/public,
reset, 시스템 row 삭제, import auth/public, verify, cleanup) 진행됐음.
재사용 가능하게 단일 명령으로 패키징.

Usage:
  export PRD_DB_URL='postgresql://...'   # NEVER paste in chat
  just seed-from-prod

추가:
- scripts/seed-from-prod.sh — pre-flight, dump, reset --no-seed,
  system-seed row 삭제, import auth→public, 검증, cleanup
- Justfile — seed-from-prod target

안전 가드:
- PRD_DB_URL 미설정 시 fail-fast + Dashboard 안내 메시지
- 모든 prerequisite (pg_dump, psql, docker, supabase) 사전 체크
- /tmp dump 파일에 PID 접미사 + trap 으로 항상 cleanup
- interactive confirm prompt (yes 입력 필수)
- 비밀번호 로테이션 reminder 출력
- post_magazines drift (#372) 미적용 PRD 일 경우 안내

Closes (옵션 #5 in spec) part of #371

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
decoded-app Ready Ready Preview, Comment Apr 30, 2026 6:29am

- 2026-04-30-db-operating-model-design.md: `date` → `updated` 필드명, tags
  를 허용 어휘 [db, ops, architecture] 로 교체 (이전 [database,
  migration, supabase, seaorm, drift, documentation] — 어휘 외 6건).
- 2026-04-23-e2e-hardening-reprioritization-design.md: `title` 더블쿼트로
  감싸 `#170)` 의 YAML comment 절단 해소 → H1_TITLE_MISMATCH 제거. tags
  를 [testing, ops] 로 정합화 (이전 infrastructure/hardening 어휘 외).

`bun run wiki:lint` 결과: 10 errors → 0 errors (TOO_MANY_RELATED 1건은
warning, CI 통과).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thxforall thxforall merged commit 533e3b4 into dev Apr 30, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in decoded-monorepo Apr 30, 2026
thxforall added a commit that referenced this pull request Apr 30, 2026
) (#379)

#371 PR #375 의 operating-model.md 후속. 동시기 머지될 #372/#373/#377/#378
의 산출물을 진입점 문서에 cross-reference 한다.

변경:
- 'dev → prod 동기화 (시드)' 섹션의 13줄 bash 블록을 `just seed-from-prod`
  (#377) 한 줄로 단축. 자세한 동작은 scripts/seed-from-prod.sh 로 위임.
- drift 패턴 표의 'SeaORM 만 변경' 행에 `post_magazines.status='failed'`
  (#372) 사례 inline 인용 (commit 6351e7c, 2026-04-22 → 45 row → 2026-04-30
  발견). nightly drift CI (#373) 도 같은 패턴 자동 감지로 안내.
- '관련 문서' 표에 nightly drift CI (#373, #378) 와 PRD→dev 시드 스크립트
  (#377) 추가.
- 변경 이력에 후속 항목 기록.

검증: bun run wiki:lint 통과 (0 errors, 1 warning).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
thxforall added a commit that referenced this pull request Apr 30, 2026
) (#386)

#371 PR #375 의 operating-model.md 후속. 동시기 머지될 #372/#373/#377/#378
의 산출물을 진입점 문서에 cross-reference 한다.

변경:
- 'dev → prod 동기화 (시드)' 섹션의 13줄 bash 블록을 `just seed-from-prod`
  (#377) 한 줄로 단축. 자세한 동작은 scripts/seed-from-prod.sh 로 위임.
- drift 패턴 표의 'SeaORM 만 변경' 행에 `post_magazines.status='failed'`
  (#372) 사례 inline 인용 (commit 6351e7c, 2026-04-22 → 45 row → 2026-04-30
  발견). nightly drift CI (#373) 도 같은 패턴 자동 감지로 안내.
- '관련 문서' 표에 nightly drift CI (#373, #378) 와 PRD→dev 시드 스크립트
  (#377) 추가.
- 변경 이력에 후속 항목 기록.

검증: bun run wiki:lint 통과 (0 errors, 1 warning).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant