feat(db): integrate Flyway for database migrations (#130)#310
feat(db): integrate Flyway for database migrations (#130)#310nanotaboada merged 7 commits intomasterfrom
Conversation
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds Flyway-based database migrations: Flyway deps and config, three versioned SQL migrations (schema + two seed sets), test profile keeps Flyway disabled and uses existing SQL scripts, updates Hibernate to validate, updates docs/changelog, and adjusts container startup/storage handling. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Assessment against linked issues
Out-of-scope changes
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #310 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 30 30
===========================================
Files 2 2
Lines 88 88
Branches 8 8
===========================================
Hits 88 88 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 280-282: The fenced code block containing the pattern
"V{version}__{description}.sql" lacks a language specifier and triggers
markdownlint MD040; update the README's fenced block that contains that pattern
to include a language identifier such as "text" or "plaintext" (e.g., change the
opening backticks to ```text) so the block is treated as plain text and the lint
rule is satisfied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d616c4db-73ae-44d0-be81-a7644529cfb1
📒 Files selected for processing (8)
CHANGELOG.mdREADME.mdpom.xmlsrc/main/resources/application.propertiessrc/main/resources/db/migration/V1__Create_players_table.sqlsrc/main/resources/db/migration/V2__Seed_starting11.sqlsrc/main/resources/db/migration/V3__Seed_substitutes.sqlsrc/test/resources/application.properties
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion (#130) Hibernate 7 (Spring Boot 4.0.0) strictly validates Boolean → BOOLEAN; INTEGER no longer satisfies the check. Update V1 migration and test DDL to declare starting11 as BOOLEAN (native in PostgreSQL; stored as 0/1 with BOOLEAN affinity in SQLite). Regenerate storage/players-sqlite3.db from the migration scripts so the pre-seeded Docker image matches. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…#130) Flyway now handles database initialization, so the seed copy logic is no longer needed. Align with the Rust entrypoint style: use a log() helper for formatted output, add Swagger UI endpoint to the startup banner, keep health check endpoint. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
baseline-on-migrate=true with baseline-version=3 caused Flyway to mark an empty database as already at V3 (due to its own schema_history table creation), skipping all migrations and leaving no players table. Remove the baseline settings so Flyway runs V1→V2→V3 normally on first start. Remove the pre-seeded storage/players-sqlite3.db from version control and the Dockerfile COPY ./hold/ layer — Flyway now creates the database and seeds all 26 players automatically. Add storage/.gitkeep and ignore storage/*.db. Update README accordingly. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Spring Boot 4.0 moved Flyway auto-configuration out of spring-boot-autoconfigure into a dedicated starter module. Adding only flyway-core to the classpath is no longer sufficient to trigger FlywayAutoConfiguration or the spring.flyway.* properties — the starter is required, following the same convention as spring-boot-starter-data-jpa, spring-boot-starter-webmvc, etc. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Around line 45-56: Update the CHANGELOG entry to reflect the final shipped
Flyway configuration: remove the assertion that `baseline-on-migrate=true` and
instead document that Flyway is enabled via `spring.flyway.enabled=true` and
configured with explicit `spring.flyway.locations` only (no
baseline-on-migrate), while tests remain disabled from Flyway and continue using
the SQLite in-memory DDL/DML approach; reference the existing mentions of
`spring.flyway.enabled`, `spring.flyway.locations`, and `baseline-on-migrate` in
the changelog text and adjust the sentence that currently states
`baseline-on-migrate=true` to match the actual shipped config.
In `@scripts/entrypoint.sh`:
- Around line 14-21: After creating the parent directory with mkdir -p
"$(dirname "$STORAGE_PATH")", add a fast-fail permissions check: verify the
parent directory is writable and that the database file at STORAGE_PATH is
writable or can be created (use a touch attempt or test -w on the file), and if
either check fails call log with a clear error including STORAGE_PATH and exit
1; update the startup block that currently logs existence to perform these
writability checks (referencing STORAGE_PATH, mkdir -p "$(dirname
"$STORAGE_PATH")" and the log function) so the script fails early with an
actionable message instead of letting the app error later.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: de2ebc3e-f890-466f-a6e4-192e79b6b3c9
⛔ Files ignored due to path filters (2)
storage/.gitkeepis excluded by!**/storage/**storage/players-sqlite3.dbis excluded by!**/*.db,!**/storage/**,!**/*.db
📒 Files selected for processing (7)
.gitignoreCHANGELOG.mdDockerfileREADME.mdpom.xmlscripts/entrypoint.shsrc/main/resources/application.properties
💤 Files with no reviewable changes (1)
- Dockerfile
✅ Files skipped from review due to trivial changes (2)
- .gitignore
- README.md
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/resources/application.properties
- pom.xml
…130) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|



Summary
flyway-coreandflyway-database-postgresqltopom.xml(Spring Boot manages the version)src/main/resources/application.properties:spring.flyway.enabled=true,baseline-on-migrate=true,baseline-version=3; switchddl-autofromnonetovalidatespring.flyway.enabled=false); tests continue using SQLite in-memory withddl.sql/dml.sqlsrc/main/resources/db/migration/with three versioned scripts:V1__Create_players_table.sql(schema),V2__Seed_starting11.sql(11 Starting XI players),V3__Seed_substitutes.sql(15 substitute players)CHANGELOG.mdandREADME.mdwith migration workflow documentationTest plan
./mvnw clean install— 40/40 tests pass, all JaCoCo coverage checks metdocker compose build— image builds successfullyvalidateis correct per issue spec)flyway_schema_historytable is created on a fresh database runstorage/players-sqlite3.dbstarts without running migrations (baselined at V3)Closes #130
🤖 Generated with Claude Code
This change is
Summary by CodeRabbit
New Features
Documentation
Chores