Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/schema-ownership-and-capability-streams/decision/decision-flyway-owns-the-schema.md
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +09:00

59 lines
2.7 KiB
Markdown

---
kind: PROJECT_DECISION
slug: flyway-owns-the-schema
title: Flyway가 스키마를 소유하고 런타임 롤은 DDL 권한을 갖지 않는다
topic: schema-ownership-and-capability-streams
project: clean-architecture-backend-template
status: 게시 전
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
rootTreeNode: decision:flyway-owns-the-schema
decisionStatus: ADOPTED
decidedOn: 2026-08-30
source:
- src/adapter/outbound/persistence-jpa/src/main/resources/db/migration
- src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/postgresql/PostgreSqlPersistenceConfig.java
- analysis/05-adapter-outbound-persistence-jpa.md
---
# Flyway가 스키마를 소유하고 런타임 롤은 DDL 권한을 갖지 않는다
## 결정문
스키마 변경은 Flyway 마이그레이션으로만 하고, 애플리케이션이 실행 시 쓰는 데이터베이스 롤에는 DDL 권한을 주지 않는다.
## 판단 이유
스키마 소유자가 둘이면 어느 쪽이 현재 상태를 만들었는지 알 수 없다. Hibernate 의 자동 생성이 켜져 있으면 마이그레이션 이력과 실제 스키마가 갈라진다.
그래서 애플리케이션은 검증 모드로만 동작한다. 스키마가 엔티티와 맞는지 확인하고 틀리면 기동에 실패한다.
권한 분리가 그 결정을 강제한다. 런타임 롤이 DDL 을 실행할 수 없으면, 실수로 켠 자동 생성이 조용히 스키마를 바꾸는 경로가 없다.
이 결정이 실제로 값을 한 사례가 있다. 컬럼 타입 불일치가 검증 모드 기동 실패로 나타났고, 자동 생성이 켜져 있었다면 그 불일치는 조용히 사라졌을 것이다. 그리고 마이그레이션 이력이 말하는 스키마와 실제 스키마가 달라졌을 것이다.
## 영향
감수하는 것
엔티티를 바꿀 때마다 마이그레이션을 함께 써야 한다. 개발 반복이 느려진다.
로컬 개발이 다른 데이터베이스에서 자동 생성으로 돌면 이 검증의 이점을 로컬에서는 얻지 못한다.
권한을 두 롤로 나눠 관리해야 한다. 마이그레이션 롤과 런타임 롤이다.
얻는 것
스키마의 현재 상태를 마이그레이션 이력으로 설명할 수 있다.
엔티티와 스키마의 불일치가 기동 실패로 나타난다. 첫 요청을 보내는 사람의 실패가 아니다.
## 근거
- **char(64)와 varchar(64) 불일치를 H2가 가리고 있었다**
이 결정이 실제로 값을 한 사례다.
- **적용된 마이그레이션의 checksum은 그것을 돌린 모든 배포에 대한 약속이다**
이 결정을 유지하는 규칙이다.
- **독립 Flyway 스트림과 baseline version 0**
스키마 소유가 능력별로 나뉘는 구조다.