# Expand→Transition→Contract

> 위험 변경 분해, static check, staging rehearsal와 배포 창

- Canonical: https://learning.reopt.ai/en/courses/prisma-production/lessons/pp-m2-concept
- Language: en
- HTML: https://learning.reopt.ai/en/courses/prisma-production/lessons/pp-m2-concept

---

[Prisma production guardrails](/en/courses/prisma-production) 2. 무중단 마이그레이션 3 / 9

# Expand→Transition→Contract

위험 변경 분해, static check, staging rehearsal와 배포 창
Concept 45 XP 9 min

DROP·RENAME·타입 축소·NOT NULL을 앱과 한 번에 배포하면 rollback이 어려워집니다. 새 구조를 추가하는 Expand, backfill·dual write·검증의 Transition, 구 구조를 제거하는 Contract로 나누고 최소 두 앱 버전이 공존하는 호환성 창을 둡니다.
프로덕션에서는 migrate deploy만 설계→dev 생성→정적 검증→staging rehearsal→승인된 production deploy 순서를 따릅니다. migration과 app pipeline을 분리해 실패 반경과 owner를 명확히 합니다.

| 단계 | 변경 | 통과 증거 |
| Expand | nullable column·index·new table | 구/신 앱 모두 동작 |
| Transition | backfill·dual read/write | 정합성·완료율·성능 |
| Contract | 구 read/write·column 제거 | 사용 0·rollback window 종료 |
| Observe | 30~60분 집중 관찰 | error·lock·slow query 정상 |

- 1 위험 SQL 탐지 DROP·ALTER TYPE·대규모 UPDATE를 CI에서 표시합니다.

- 2 호환성 설계 구·신 앱이 동시에 동작하는 schema contract를 만듭니다.

- 3 Rehearsal staging 데이터 규모와 timing으로 실행·rollback을 연습합니다.

- 4 작은 배포 핵심 테이블은 한 번에 하나, 저트래픽 창에 적용합니다.

실무에 남길 기준

- 파괴적 변경은 앱 코드와 별도 릴리즈로 분리한다
- migrate status·diff로 drift를 배포 전에 확인한다
- Contract는 구 경로 사용이 0이라는 관측 뒤에만 실행한다

[Previous](/en/courses/prisma-production/lessons/pp-m1-quiz) Got it · Continue

---

Site guide for agents: https://learning.reopt.ai/llms.txt · Sitemap: https://learning.reopt.ai/sitemap.xml · Contact: https://learning.reopt.ai/contact
