Skip to content

Commit 018c248

Browse files
committed
v0.3.0: BUILTIN schema management is the new default
v0.2.0 made schema management opt-in (default NONE) which forced users without Flyway/Liquibase to copy DDL manually before their first run. That was poor UX for the most common case. v0.3.0 flips the default to BUILTIN — the starter runs CREATE TABLE IF NOT EXISTS on every startup via Spring Boot's DataSourceScriptDatabaseInitializer. The SQL is idempotent (IF NOT EXISTS clauses), so re-running on every boot is a no-op once the table exists. Three strategies now: - BUILTIN (default) — starter creates the table; no migration tool needed - FLYWAY — appends classpath:db/api-log to spring.flyway.locations - NONE — starter does not touch the schema; consumer applies the DDL Implementation: - ApiLogProperties.Schema.Management: BUILTIN, FLYWAY, NONE (default BUILTIN) - ApiLogSchemaInitializer extends DataSourceScriptDatabaseInitializer so JpaBaseConfiguration auto-DependsOn it — the EntityManagerFactory waits for schema creation before validating entities (avoids ddl-auto=validate failure on fresh DBs). - V1.0__create_api_log.sql: added IF NOT EXISTS to CREATE TABLE and CREATE INDEX statements. Flyway is fine with this (it tracks migrations by version, not by SQL effect). Tests pinned to schema.management=builtin in src/test/resources/application.properties. Docs (installation, quickstart, configuration ref, schema ref, changelog) updated to lead with BUILTIN; FLYWAY and NONE are documented as alternatives for teams with specific schema-management policies. Breaking from v0.2.0 only for users who relied on the v0.2.0 NONE default; full migration notes in docs/changelog.md.
1 parent 4682774 commit 018c248

18 files changed

Lines changed: 278 additions & 175 deletions

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ The source of truth for the entries below is [docs/changelog.md](docs/changelog.
77

88
## [Unreleased]
99

10+
## [0.3.0] — BUILTIN schema management is the new default
11+
12+
### Changed
13+
14+
- **`BUILTIN` is now the default for `api.log.schema.management`.** The starter runs `CREATE TABLE IF NOT EXISTS` on startup via Spring Boot's `DataSourceScriptDatabaseInitializer` — no migration tool needed. Flips v0.2.0's `NONE` default which left first-time users with a missing table.
15+
- `V1.0__create_api_log.sql` now uses `IF NOT EXISTS` clauses, idempotent and safe to re-run on every boot.
16+
17+
Three strategies now: `builtin` (default), `flyway`, `none`. See [docs/changelog.md](docs/changelog.md#030--builtin-schema-management-is-the-new-default) for the full v0.2.0 migration guide.
18+
1019
## [0.2.0] — Schema management opt-in
1120

1221
### Changed
@@ -23,6 +32,7 @@ See [docs/changelog.md](docs/changelog.md#020--schema-management-opt-in) for the
2332

2433
First public release. See [docs/changelog.md](docs/changelog.md#010--initial-release) for details.
2534

26-
[Unreleased]: https://github.com/devslab-kr/api-log/compare/v0.2.0...HEAD
35+
[Unreleased]: https://github.com/devslab-kr/api-log/compare/v0.3.0...HEAD
36+
[0.3.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.3.0
2737
[0.2.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.2.0
2838
[0.1.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.1.0

README.ko.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ CompletableFuture<ApiResponse> future = restApiClient.postAsync("/api/users", us
165165
<dependency>
166166
<groupId>kr.devslab</groupId>
167167
<artifactId>api-log-spring-boot-starter</artifactId>
168-
<version>0.2.0</version>
168+
<version>0.3.0</version>
169169
</dependency>
170170
```
171171

@@ -227,19 +227,21 @@ api:
227227
log:
228228
enabled: true # 기본값 — false면 전체 인프라 비활성화
229229
schema:
230-
management: none # 기본값 — 아래 "스키마 관리" 참고
230+
management: builtin # 기본값 — 아래 "스키마 관리" 참고
231231
```
232232
233233
- **PostgreSQL DataSource** (JSONB 컬럼 사용 위해 필수)
234234
- **ObjectMapper** Bean (Spring Boot 기본 구성으로 충분)
235-
- `api_log` 테이블 생성 방법 — DDL을 직접 적용하거나, 번들 Flyway 마이그레이션을 옵트인
236235
237-
### 스키마 관리 (v0.2.0 변경)
236+
`api_log` 테이블은 첫 부팅 시 스타터가 자동 생성 — 별도 설정 불필요.
238237

239-
`api_log` 테이블은 **자동으로 생성되지 않습니다.** 두 가지 옵션:
238+
### 스키마 관리
240239

241-
1. **DDL 직접 적용** (기본값, 운영 권장) — [스키마 레퍼런스](https://api-log.devslab.kr/ko/reference/schema/) 참고. 본인 Flyway/Liquibase/수동 흐름에 SQL을 넣으세요.
242-
2. **번들 마이그레이션 옵트인** — Flyway 의존성 추가 + `api.log.schema.management=flyway`. 스타터가 `spring.flyway.locations`에 `classpath:db/api-log` 추가.
240+
`api.log.schema.management`로 `api_log` 테이블 생성 방식 선택:
241+
242+
- **`builtin`** (기본) — 스타터가 부팅 시 `CREATE TABLE IF NOT EXISTS` 실행. 멱등적, 마이그레이션 도구 불필요. 그냥 동작합니다.
243+
- **`flyway`** — 사용자 Flyway 흐름에 등록 (`flyway_schema_history`가 추적). `flyway-core` 클래스패스 필요.
244+
- **`none`** — 스타터가 스키마에 손 안 댐. Liquibase / 수동 `psql` / 본인 흐름으로 DDL 직접 적용. SQL은 [스키마 레퍼런스](https://api-log.devslab.kr/ko/reference/schema/) 참고.
243245

244246
전체 설치 가이드: [api-log.devslab.kr/ko/getting-started/installation](https://api-log.devslab.kr/ko/getting-started/installation/).
245247

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ PostgreSQL (api_log · JSONB columns)
7373
<dependency>
7474
<groupId>kr.devslab</groupId>
7575
<artifactId>api-log-spring-boot-starter</artifactId>
76-
<version>0.2.0</version>
76+
<version>0.3.0</version>
7777
</dependency>
7878
```
7979

8080
### Gradle
8181

8282
```kotlin
83-
implementation("kr.devslab:api-log-spring-boot-starter:0.2.0")
83+
implementation("kr.devslab:api-log-spring-boot-starter:0.3.0")
8484
```
8585

8686
## Configuration
@@ -90,21 +90,23 @@ api:
9090
log:
9191
enabled: true # default — set to false to disable the whole infrastructure
9292
schema:
93-
management: none # default — see "Schema" below
93+
management: builtin # default — see "Schema" below
9494
```
9595
9696
You bring your own:
9797
9898
- `DataSource` pointing at a PostgreSQL database
9999
- `ObjectMapper` bean (Spring Boot's auto-config is fine)
100-
- Either the `api_log` table created via your own migration tool, OR the bundled Flyway migration (opt in below)
100+
101+
The `api_log` table is created for you on first boot — no other setup needed.
101102

102103
### Schema
103104

104-
The `api_log` table is **not** created automatically. Two options:
105+
`api.log.schema.management` selects how the `api_log` table is provisioned:
105106

106-
1. **Apply the DDL yourself** (default, recommended for production) — see the [Schema reference](https://api-log.devslab.kr/reference/schema/) for the SQL, then put it in your own Flyway/Liquibase/manual flow.
107-
2. **Opt in to the bundled migration** — add Flyway to your dependencies and set `api.log.schema.management=flyway`. The starter then appends `classpath:db/api-log` to your Flyway locations.
107+
- **`builtin`** (default) — the starter runs `CREATE TABLE IF NOT EXISTS` on startup. Idempotent, requires no migration tool. Just works.
108+
- **`flyway`** — register with the consumer's Flyway flow (`flyway_schema_history` tracks the migration). Requires `flyway-core` on the classpath.
109+
- **`none`** — the starter does not touch the schema. Apply the DDL yourself via Liquibase / manual `psql` / your own flow. See the [Schema reference](https://api-log.devslab.kr/reference/schema/) for the SQL.
108110

109111
Full installation guide: [api-log.devslab.kr/getting-started/installation](https://api-log.devslab.kr/getting-started/installation/).
110112

docs/changelog.ko.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@
66

77
## [Unreleased]
88

9+
## [0.3.0] — BUILTIN 스키마 관리가 새 기본값
10+
11+
### Changed
12+
13+
- **BUILTIN이 새 기본 스키마 관리 전략.** v0.2.0이 스키마 관리를 옵트인(`NONE` 기본)으로 만들었지만, Flyway/Liquibase 안 쓰는 사용자는 첫 부팅에서 "테이블 없음" 에러를 봐야 했습니다. v0.3.0은 기본값을 `BUILTIN`으로 뒤집어 — 스타터가 Spring Boot의 `DataSourceScriptDatabaseInitializer``CREATE TABLE IF NOT EXISTS`를 자동 실행. 테이블이 그냥 존재합니다.
14+
- `V1.0__create_api_log.sql``IF NOT EXISTS` 절을 사용해 멱등적 — 매 부팅마다 안전하게 재실행 가능. Flyway도 문제 없음 (`flyway_schema_history` 행이 핵심, SQL 결과가 아님).
15+
16+
### 전략 정리 (v0.3.0 이후)
17+
18+
- `api.log.schema.management=builtin` (기본) — 스타터가 부팅 시 테이블 생성
19+
- `api.log.schema.management=flyway` — 스타터가 `FlywayConfigurationCustomizer` 등록 (Flyway 의존성 필요)
20+
- `api.log.schema.management=none` — 스타터가 스키마에 손 안 댐; 사용자가 직접 DDL 적용
21+
22+
### v0.2.0에서 마이그레이션
23+
24+
- **`management=flyway` 명시한 경우:** 변경 불필요.
25+
- **`management=none` 명시한 경우:** 변경 불필요.
26+
- **`management`를 설정 안 한 경우 (v0.2.0 기본 NONE에 의존, 다른 곳에서 DDL 적용 중):** `management=none`을 명시해서 기존 동작 유지하거나, BUILTIN이 동작하도록 그대로 두기 (멱등적이라 기존 테이블과 충돌 없음).
27+
928
## [0.2.0] — 스키마 관리 옵트인
1029

1130
### Changed
@@ -62,6 +81,7 @@ v0.1.0의 자동 마이그레이션에 의존하고 있었다면:
6281
- `ApiLogAutoConfiguration`을 통한 자동 구성, `@ConditionalOnMissingBean` 오버라이드.
6382
- Testcontainers 기반 PostgreSQL 통합 테스트 31개.
6483

65-
[Unreleased]: https://github.com/devslab-kr/api-log/compare/v0.2.0...HEAD
84+
[Unreleased]: https://github.com/devslab-kr/api-log/compare/v0.3.0...HEAD
85+
[0.3.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.3.0
6686
[0.2.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.2.0
6787
[0.1.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.1.0

docs/changelog.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
66

77
## [Unreleased]
88

9+
## [0.3.0] — BUILTIN schema management is the new default
10+
11+
### Changed
12+
13+
- **BUILTIN is now the default schema management strategy.** v0.2.0 made schema management opt-in with `NONE` as the default, but that left users without Flyway/Liquibase staring at a "table doesn't exist" error on first boot. v0.3.0 flips the default to `BUILTIN` — the starter runs `CREATE TABLE IF NOT EXISTS` automatically via Spring Boot's `DataSourceScriptDatabaseInitializer`, so the table just exists.
14+
- `V1.0__create_api_log.sql` now uses `IF NOT EXISTS` clauses, making it idempotent and safe to re-run on every boot. Flyway is fine with this; the version row in `flyway_schema_history` is what matters, not whether the SQL did anything.
15+
16+
### Strategy summary (after v0.3.0)
17+
18+
- `api.log.schema.management=builtin` (default) — starter creates the table on startup
19+
- `api.log.schema.management=flyway` — starter registers a `FlywayConfigurationCustomizer` (requires Flyway on classpath)
20+
- `api.log.schema.management=none` — starter does not touch the schema; you apply the DDL yourself
21+
22+
### Migration from v0.2.0
23+
24+
- **You had `management=flyway` set explicitly:** no change needed.
25+
- **You had `management=none` set explicitly:** no change needed.
26+
- **You did not set `management` (relying on the v0.2.0 default `NONE` and applying the DDL elsewhere):** either set `management=none` explicitly to preserve old behavior, or let BUILTIN take over (it's idempotent, so it won't fight your existing table).
27+
928
## [0.2.0] — Schema management opt-in
1029

1130
### Changed
@@ -62,6 +81,7 @@ First public release. Repackaged as a standalone Spring Boot starter.
6281
- Auto-configuration via `ApiLogAutoConfiguration` with `@ConditionalOnMissingBean` overrides.
6382
- 31 tests including PostgreSQL integration via Testcontainers.
6483

65-
[Unreleased]: https://github.com/devslab-kr/api-log/compare/v0.2.0...HEAD
84+
[Unreleased]: https://github.com/devslab-kr/api-log/compare/v0.3.0...HEAD
85+
[0.3.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.3.0
6686
[0.2.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.2.0
6787
[0.1.0]: https://github.com/devslab-kr/api-log/releases/tag/v0.1.0

docs/getting-started/installation.ko.md

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
<dependency>
1515
<groupId>kr.devslab</groupId>
1616
<artifactId>api-log-spring-boot-starter</artifactId>
17-
<version>0.2.0</version>
17+
<version>0.3.0</version>
1818
</dependency>
1919
```
2020

2121
=== "Gradle (Kotlin DSL)"
2222

2323
```kotlin
2424
dependencies {
25-
implementation("kr.devslab:api-log-spring-boot-starter:0.2.0")
25+
implementation("kr.devslab:api-log-spring-boot-starter:0.3.0")
2626
}
2727
```
2828

2929
=== "Gradle (Groovy)"
3030

3131
```groovy
3232
dependencies {
33-
implementation 'kr.devslab:api-log-spring-boot-starter:0.2.0'
33+
implementation 'kr.devslab:api-log-spring-boot-starter:0.3.0'
3434
}
3535
```
3636

3737
!!! tip "최신 버전"
38-
`0.2.0`[Maven Central](https://central.sonatype.com/artifact/kr.devslab/api-log-spring-boot-starter)의 최신 버전으로 교체.
38+
`0.3.0`[Maven Central](https://central.sonatype.com/artifact/kr.devslab/api-log-spring-boot-starter)의 최신 버전으로 교체.
3939

4040
## 스타터가 자동으로 가져오는 의존성
4141

@@ -45,35 +45,14 @@
4545
- `jackson-module-blackbird` (고성능 JSON 직렬화)
4646
- `postgresql` JDBC 드라이버 (runtime)
4747

48-
!!! info "Flyway는 옵셔널 (v0.2.0부터)"
49-
Flyway는 더 이상 transitive 의존성이 아닙니다. 번들된 마이그레이션을 자동으로 적용하려면 ([스키마 관리](#schema-management) 참고) 직접 추가하세요:
50-
51-
=== "Maven"
52-
53-
```xml
54-
<dependency>
55-
<groupId>org.flywaydb</groupId>
56-
<artifactId>flyway-core</artifactId>
57-
</dependency>
58-
<dependency>
59-
<groupId>org.flywaydb</groupId>
60-
<artifactId>flyway-database-postgresql</artifactId>
61-
<scope>runtime</scope>
62-
</dependency>
63-
```
64-
65-
=== "Gradle (Kotlin DSL)"
66-
67-
```kotlin
68-
implementation("org.flywaydb:flyway-core")
69-
runtimeOnly("org.flywaydb:flyway-database-postgresql")
70-
```
48+
Flyway는 **옵셔널**`api.log.schema.management=flyway`로 설정할 때만 필요합니다 (아래 [스키마 관리](#schema-management) 참고). 기본값(BUILTIN)은 Flyway 불필요.
7149

7250
## 직접 제공해야 하는 것
7351

7452
- **PostgreSQL `DataSource`** — 스타터가 DB 접속 정보를 만들어주지는 않습니다
7553
- **`ObjectMapper`** — Spring Boot 자동 구성으로 충분
76-
- `api_log` 테이블 생성 방법 — DDL을 직접 적용하거나, 번들 Flyway 마이그레이션을 옵트인 (아래)
54+
55+
여기까지. 기본 설정이면 `api_log` 테이블은 첫 부팅에 자동 생성됩니다.
7756

7857
```yaml title="application.yml"
7958
spring:
@@ -85,11 +64,12 @@ spring:
8564
virtual:
8665
enabled: true # Java 21+ 권장
8766

67+
# 둘 다 합리적인 기본값 — 비기본 동작이 필요할 때만 명시.
8868
api:
8969
log:
9070
enabled: true # 기본값 — false면 전체 인프라 비활성화
9171
schema:
92-
management: none # 기본값 — 아래 "스키마 관리" 참고
72+
management: builtin # 기본값 — 아래 "스키마 관리" 참고
9373
```
9474
9575
## 자동 구성이 하는 일
@@ -99,28 +79,40 @@ api:
9979
- `ApiLogService` — 영속화 오케스트레이터 (`ObjectMapper` 빈이 있어야 활성화)
10080
- `ApiEventListener` — 이벤트를 서비스로 연결하는 `@EventListener` (async)
10181
- `RetryConfig` — Spring Retry 통합을 위한 `@EnableRetry` 활성화
82+
- `ApiLogSchemaInitializer` — 부팅 시 `CREATE TABLE IF NOT EXISTS` 실행 (`schema.management=builtin` 활성화 시, 즉 기본값)
10283
- JPA `@EntityScan` 및 `@EnableJpaRepositories` (`kr.devslab.apilog.model`, `kr.devslab.apilog.repository`)
10384

10485
모든 빈은 `@ConditionalOnMissingBean`. 직접 빈을 정의하면 오버라이드됩니다.
10586

10687
## 스키마 관리 { #schema-management }
10788

108-
`api_log` 테이블은 **자동으로 생성되지 않습니다.** `api.log.schema.management`로 어떻게 만들지 선택합니다:
89+
`api.log.schema.management`로 `api_log` 테이블 생성 방식 선택:
10990

110-
=== "NONE (기본) — DDL 직접 적용"
91+
=== "BUILTIN (기본) — 스타터가 처리"
11192

112-
[스키마 레퍼런스](../reference/schema.md)의 SQL을 다음 중 하나에 넣으세요:
93+
매 부팅마다 스타터가 번들된 `V1.0__create_api_log.sql`을 사용자의 `DataSource`에 실행합니다. DDL이 `CREATE TABLE IF NOT EXISTS` / `CREATE INDEX IF NOT EXISTS`이라 멱등적 — 테이블이 이미 있으면 매번 no-op.
11394

114-
- 본인 프로젝트의 Flyway 마이그레이션, 또는
115-
- 본인 프로젝트의 Liquibase changelog, 또는
116-
- 배포 시 수동 `psql` 실행, 또는
117-
- 본인이 이미 쓰고 있는 스키마 관리 흐름
95+
추가 의존성 없음. 외부 마이그레이션 도구 없음. 그냥 동작.
11896

119-
**기본값**입니다 — 운영 환경 대부분은 이미 마이그레이션을 관리하고 있고, 서드파티 라이브러리가 자기 마음대로 스키마에 손대는 걸 원하지 않기 때문입니다.
97+
Spring Boot의 [`DataSourceScriptDatabaseInitializer`](https://docs.spring.io/spring-boot/api/java/org/springframework/boot/jdbc/init/DataSourceScriptDatabaseInitializer.html)를 통해 적용되므로 JPA 엔티티 검증보다 먼저 실행 — 빈 DB에서 Hibernate `ddl-auto=validate`가 실패하지 않음.
12098

121-
=== "FLYWAY — 스타터에 위임"
99+
=== "FLYWAY — 사용자 Flyway에 등록"
100+
101+
Flyway 의존성 추가:
102+
103+
```xml
104+
<dependency>
105+
<groupId>org.flywaydb</groupId>
106+
<artifactId>flyway-core</artifactId>
107+
</dependency>
108+
<dependency>
109+
<groupId>org.flywaydb</groupId>
110+
<artifactId>flyway-database-postgresql</artifactId>
111+
<scope>runtime</scope>
112+
</dependency>
113+
```
122114

123-
위에서 Flyway 의존성 추가 후:
115+
그리고 설정:
124116

125117
```yaml title="application.yml"
126118
api:
@@ -129,19 +121,32 @@ api:
129121
management: flyway
130122
```
131123

132-
스타터가 `FlywayConfigurationCustomizer`를 등록해 기존 `spring.flyway.locations`에 `classpath:db/api-log`를 추가합니다. 본인 마이그레이션과 우리 마이그레이션이 함께 실행됨 — 충돌·중복 없음.
124+
스타터가 `FlywayConfigurationCustomizer`를 등록해 기존 `spring.flyway.locations`에 `classpath:db/api-log` 추가. 본인 마이그레이션과 함께 실행되며 `flyway_schema_history`에 `V1.0__create_api_log`가 추적됨.
125+
126+
팀이 `flyway_schema_history` 행을 스키마 변경의 권위 있는 기록으로 다룬다면 이 옵션을 선택.
127+
128+
=== "NONE — DDL 직접 적용"
129+
130+
스타터가 스키마에 손 안 댐. [스키마 레퍼런스](../reference/schema.md)의 SQL을 다음 중 하나에 넣으세요:
131+
132+
- 본인 프로젝트의 Liquibase changelog, 또는
133+
- 배포 시 수동 `psql` 실행, 또는
134+
- 본인의 시작 스크립트
135+
136+
```yaml title="application.yml"
137+
api:
138+
log:
139+
schema:
140+
management: none
141+
```
133142

134-
번들 마이그레이션 `V1.0__create_api_log.sql`이 `api_log` 테이블과 `request_id`, `timestamp` 인덱스를 생성합니다.
143+
팀 정책상 서드파티 라이브러리가 스키마에 손대지 못하게 하거나, 다른 인프라로 이미 테이블이 만들어져 있어 충돌을 피하고 싶을 때 선택.
135144

136145
## 설치 확인
137146

138-
의존성 추가 후 앱 실행 시 두 가지로 확인:
147+
의존성 추가 후 앱 실행 시:
139148

140149
1. **자동 구성 로드** — `--debug` 옵션으로 `ApiLogAutoConfiguration matched` 로그
141-
2. **`api_log` 테이블 존재** — DDL을 수동으로 적용했거나, Flyway가 다음 로그를 남겼거나:
142-
```text
143-
o.f.c.i.command.DbMigrate : Migrating schema "public" to version "1.0 - create api log"
144-
o.f.c.i.command.DbMigrate : Successfully applied 1 migration to schema "public"
145-
```
150+
2. **`api_log` 테이블 존재** — BUILTIN이면 자동 생성. FLYWAY면 Flyway 표준 "applied 1 migration" 로그. NONE이면 본인이 적용.
146151

147152
이어서 [빠른 시작](quickstart.md)으로 첫 번째 로그를 기록해보세요.

0 commit comments

Comments
 (0)