backend
無料Backend Java — Spring Boot controllers/services, JUnit controller tests, MakeMe. Read this first for any backend work. Use when working on the Java Spring backend.
日本語の概要は準備中です。原文の説明を表示しています。
Database migration, Flyway, SQL migrations, schema changes, database versioning, migration files, squashing historical migrations. Use when adding or changing Flyway migrations or schema.
日本語の概要は準備中です。原文の説明を表示しています。
実行スコア 未検証
インストール方法を見るインストールする前に、エージェントに与えられる指示の中身を確認できます。
Use this rule when:
The project uses Flyway for database migrations, configured in Spring Boot.
backend/src/main/resources/db/migration/backend/src/main/java/db/migration/V{version}__{description}.sql (or .java)
V300000352__rename_a_column.sql (version must exceed 300000351)The project uses versioned files named V{number}__{description}.sql. The current full application DDL is collapsed into V100000000__baseline.sql; the upgrade migrations after it run in order on every install, and V300000351__db_migration_placeholder.sql is the newest file: a no-op tip placeholder above every version ever applied. Versions 300000330, 300000339, and 300000350 are retired — their migrations were deleted after production applied them — and stay reserved in flyway_schema_history.
New migrations need to use a greater version number than 300000351.
flyway.repair() then flyway.migrate() (FlyWayFreeVersionRealMigration). repair() is what makes squashing safe on existing databases (checksum realign + remove history for deleted files). Deleting the newest applied migration file is different: until a newer version ships, databases that recorded it treat it as a future migration and keep its row unchanged; the next newer migration's startup then marks it deleted.backend-development rule for test execution)FlyWayFreeVersionRealMigration runs on ApplicationReadyEvent, after the instance is ready, so new code can serve requests before its own migrations finish. Ship a schema change that code must not see early in two releases: first the compatible schema change (for example relaxing a column to nullable while code still writes it), then the code that relies on it.repair(), until the data is fixed. Production runs two instances and the deploy replaces them one at a time (--max-surge 0 --max-unavailable 1), so the other instance keeps serving; on a single instance the same failure is an outage.V300000338__DropNotebookGitBindingBundleBytes does.V100000000__baseline.sql holds the collapsed full DDL (fresh installs).Rare maintenance: collapse applied migrations into the baseline so the repo keeps only baseline + tip placeholder (+ any newer work after the next tip). Do not squash casually. Production (and other long-lived DBs) survive because startup always repair()s before migrate().
flyway_schema_history, so check git history and an existing database before picking. Reusing a version (or an old placeholder that already sits behind later versions) is wrong.flyway_schema_history.V100000000). Replace file contents only. Renaming/renumbering the baseline makes Flyway treat it as a new pending migration and can run full CREATE DDL on an existing DB.flyway_schema_history (match the header comment on the current baseline).resources/db/migration/, Java under java/db/migration/), versions deleted in git history, and SELECT MAX(version) FROM flyway_schema_history on a long-lived database.V{max+1}__db_migration_placeholder.sql, with a short comment that future migrations must use a greater version.flyway_schema_history. Freeze further migrations.flyway_schema_history).V100000000__baseline.sql with that dump (same filename/version). Delete every migration file (.sql and .java) with version strictly between baseline and the tip placeholder. Keep baseline + tip placeholder.flyway_schema_history looks sane (baseline checksum repaired; deleted versions gone; tip still present).docs/database-erd.md if the collapsed schema should be re-exported (see below).DELETE, gated UPDATE)Prefer not to ship one-off data cleanup in the permanent Flyway chain. Cosmetic or historical row fixes belong in a one-time ops script, not a migration that runs on every startup forever.
If destructive DML must ship as a migration:
WHERE ${some_repair_gate} and declare that Flyway placeholder in every application profile (spring.flyway.placeholders) with the default 1=0, so the migration is a no-op in dev/test/CI. Enable it (1=1) only for the deliberate production deploy that ships the migration, then remove the production override after confirming Flyway applied it. Drop the placeholder from the profiles once the gated migration is spent. While the migration is pending, add a focused migration test that proves the default no-op and intended enabled selection; remove that migration-only test after successful production application because committed migrations are immutable and no product behavior depends on their test harness.DELETE — CASCADE edges extend the blast radius; NO ACTION / RESTRICT edges block it. Regenerate docs/database-erd.md and read delete-rule labels on every edge in the closure. For declared hard-delete roots, DeletableEntityFkClosureTest fails CI when a restricting FK enters the subtree.migrateTestDB (see ci.yml) runs migrations against an empty database, so a DELETE that matches zero rows always passes. Row-selection tests and schema-structural guards are both required.After adding or changing schema migrations, regenerate docs/database-erd.md so the Mermaid ERD stays aligned with Flyway. Follow the database-erd skill (.agents/skills/database-erd/SKILL.md): run CURSOR_DEV=true nix develop -c pnpm export:database-erd (or python3 scripts/export_database_erd.py) against a migrated local MySQL schema. Edge labels include DELETE_RULE — use them when reviewing any destructive change.
まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
Backend Java — Spring Boot controllers/services, JUnit controller tests, MakeMe. Read this first for any backend work. Use when working on the Java Spring backend.
日本語の概要は準備中です。原文の説明を表示しています。
Backend Java production code, Spring Boot controllers/services/repositories, controller return values, imports, schema ERD pointer. Use when editing backend production Java.
日本語の概要は準備中です。原文の説明を表示しています。
Backend Java tests, controller-level stable-boundary tests, JUnit, @Nested, MakeMe builders, @Transactional, parameterized tests. Use when writing or changing backend JUnit tests.
日本語の概要は準備中です。原文の説明を表示しています。
related to donut CLI. Use when working on donut-cli.
日本語の概要は準備中です。原文の説明を表示しています。
Set up and run the Donut dev environment on Cursor Cloud VM (no Nix). Use when working on Cloud VM, running tests on Cloud VM, or encountering command errors related to missing nix. Triggers on: cloud VM, cloud agent, no nix available, /workspace path.
日本語の概要は準備中です。原文の説明を表示しています。
Regenerate docs/database-erd.md from MySQL information_schema (Mermaid ERD: foreign keys and key columns). Use after Flyway schema changes, new migrations, or when the diagram is stale. Triggers on: database ERD, database-erd.md, export_database_erd, schema diagram, ER diagram after migration.
日本語の概要は準備中です。原文の説明を表示しています。