313-frameworks-spring-db-migrations-flyway

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spring — Database migrations (Flyway)

Spring — Database migrations (Flyway)

Apply Flyway migration guidelines for Spring Boot.
What is covered in this Skill?
  • flyway-core and database-specific Flyway modules (e.g. PostgreSQL) with Spring Boot BOM
  • Versioned SQL under
    src/main/resources/db/migration
    (
    V{version}__{description}.sql
    )
  • spring.flyway.*
    properties: locations, baseline-on-migrate, validate-on-migrate
  • Optional Java migrations (
    BaseJavaMigration
    ) for data backfills
  • Forward-only discipline: do not rewrite applied migrations in shared environments
  • Coordination with
    @311-frameworks-spring-jdbc
    and
    @312-frameworks-spring-data-jdbc
Scope: Apply recommendations based on the reference rules and good/bad examples.
应用Spring Boot的Flyway迁移指南。
本技能涵盖哪些内容?
  • 基于Spring Boot BOM的flyway-core及数据库专属Flyway模块(例如PostgreSQL)
  • src/main/resources/db/migration
    下的版本化SQL文件(命名格式为
    V{version}__{description}.sql
  • spring.flyway.*
    属性:locations、baseline-on-migrate、validate-on-migrate
  • 用于数据回填的可选Java迁移(
    BaseJavaMigration
  • 仅向前迁移准则:在共享环境中不要重写已应用的迁移
  • @311-frameworks-spring-jdbc
    @312-frameworks-spring-data-jdbc
    的协同
适用范围: 根据参考规则和正反示例应用建议。

Constraints

约束条件

Before applying Flyway or SQL changes, ensure the project compiles. After improvements, run full verification.
  • MANDATORY: Run
    ./mvnw compile
    or
    mvn compile
    before applying any change
  • SAFETY: If compilation fails, stop immediately
  • VERIFY: Run
    ./mvnw clean verify
    or
    mvn clean verify
    after applying improvements
  • BEFORE APPLYING: Read the reference for detailed rules and good/bad patterns
在应用Flyway或SQL变更前,确保项目可编译。完成改进后,运行完整验证。
  • 强制要求:在进行任何变更前运行
    ./mvnw compile
    mvn compile
  • 安全提示:如果编译失败,立即停止操作
  • 验证步骤:完成改进后运行
    ./mvnw clean verify
    mvn clean verify
  • 应用前须知:阅读参考文档了解详细规则和正反模式

When to use this skill

何时使用本技能

  • Add or review Flyway migrations in a Spring Boot project
  • Configure spring.flyway or db/migration layout
  • 在Spring Boot项目中添加或审核Flyway迁移
  • 配置spring.flyway或db/migration目录结构

Reference

参考资料

For detailed guidance, examples, and constraints, see references/313-frameworks-spring-db-migrations-flyway.md.
如需详细指南、示例和约束条件,请查看references/313-frameworks-spring-db-migrations-flyway.md