C.W.K.
Stream
Lesson 05 of 10 · published

Local, Staging, Production: 다르지만 같음

~12 min · apps, environments

Level 0스키마 새싹
0 XP0/86 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

3-환경 story

대부분 팀이 Postgres 환경 셋: local (개발자 머신), staging (통합용 호스트 클론), production (진짜). 스키마는 셋 가로질러 동일해야; 데이터는 안 그래야.

환경마다 바뀌는 거

  • Connection string (다른 host/credential).
  • 데이터 (dev 엔 seed, staging 엔 현실적 가짜, prod 엔 진짜).
  • 리소스 사이즈 (dev 1GB, staging 4GB, prod 는 필요한 만큼).
  • Backup cadence (dev 없음, staging 시간별, prod 연속).
  • SSL (local off, staging/prod required).

바뀌면 안 되는 거

  • 스키마 (마이그레이션 관리 — 같은 마이그레이션, 같은 순서, 같은 최종 상태).
  • Postgres 메이저 버전. Prod 에 돌리는 같은 메이저에 테스트. Planner, JSON path, generated column 의 차이가 물 수 있음.
  • 설치된 extension 집합.

Code

환경별 config·bash
# .env.local
DATABASE_URL=postgresql://app:dev@localhost:5432/myapp_dev

# .env.staging (CI / 호스팅 플랫폼)
DATABASE_URL=postgresql://app:****@staging-db.example.com/myapp?sslmode=require

# .env.production
DATABASE_URL=postgresql://app:****@prod-db.example.com/myapp?sslmode=require
로컬 Postgres 띄우기·bash
# Native install (선호 — docker 오버헤드 없음)
brew install postgresql@17
brew services start postgresql@17
createdb myapp_dev

# 또는 클라우드 무료 티어로:
# Supabase, Neon, Railway, Render — 다 free Postgres 있음

External links

Exercise

프로젝트 감사: local, staging, prod 가 모두 같은 Postgres 메이저? 같은 extension 집합? 같은 마이그레이션 history? drift 나열 + 정렬 계획.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.