Conversation
✅ Deploy Preview for kcloud-platform-iot ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
审查者指南此 PR 将在管理服务中用于数据库迁移的 Liquibase 替换为 Flyway,相应更新配置和依赖,清理遗留的 Liquibase 元数据结构,并为常规版和独立版管理端部署中的国际化(i18n)菜单表引入基于 Flyway 的迁移脚本。 使用 Flyway 迁移的 Spring Boot 启动时序图sequenceDiagram
participant SpringBoot as SpringBootAdminApp
participant Flyway as FlywayAutoConfiguration
participant DB as PostgreSQLAdminDatabase
SpringBoot->>SpringBoot: loadApplicationContext
SpringBoot->>Flyway: createFlywayBeans
Flyway->>DB: connect
Flyway->>DB: checkFlywaySchemaHistory
Flyway->>DB: scanAppliedMigrations
Flyway->>SpringBoot: readProperties(locations,baselineOnMigrate,baselineVersion,validateOnMigrate)
Flyway->>DB: scanPendingMigrations(classpath_db_migration)
Flyway->>DB: applyMigration(V1_202603092010__create_i18n_menu)
Flyway->>DB: applyMigration(V2_202603092010__insert_i18n_menu)
Flyway->>DB: applyMigration(V3_202603092010__update_menu)
Flyway-->>SpringBoot: migrationsComplete
SpringBoot-->>SpringBoot: finishStartup
sys_i18n_menu 及相关菜单数据的 ER 图erDiagram
SYS_MENU {
bigint id PK
varchar name
varchar path
}
SYS_I18N_MENU {
bigint id PK
bigint creator
bigint editor
timestamp create_time
timestamp update_time
smallint del_flag
int version
bigint tenant_id
bigint dept_id
varchar code
varchar menu
}
SYS_MENU ||--o{ SYS_I18N_MENU : localized_by
文件级变更
提示与命令与 Sourcery 交互
自定义你的使用体验访问你的 控制台 以:
获取帮助Original review guide in EnglishReviewer's GuideThis PR replaces Liquibase with Flyway for database migrations in the admin services, updates configuration and dependencies accordingly, cleans up legacy Liquibase metadata structures, and introduces Flyway-based migration scripts for the internationalization (i18n) menu tables in both the regular and standalone admin deployments. Sequence diagram for Spring Boot startup with Flyway migrationssequenceDiagram
participant SpringBoot as SpringBootAdminApp
participant Flyway as FlywayAutoConfiguration
participant DB as PostgreSQLAdminDatabase
SpringBoot->>SpringBoot: loadApplicationContext
SpringBoot->>Flyway: createFlywayBeans
Flyway->>DB: connect
Flyway->>DB: checkFlywaySchemaHistory
Flyway->>DB: scanAppliedMigrations
Flyway->>SpringBoot: readProperties(locations,baselineOnMigrate,baselineVersion,validateOnMigrate)
Flyway->>DB: scanPendingMigrations(classpath_db_migration)
Flyway->>DB: applyMigration(V1_202603092010__create_i18n_menu)
Flyway->>DB: applyMigration(V2_202603092010__insert_i18n_menu)
Flyway->>DB: applyMigration(V3_202603092010__update_menu)
Flyway-->>SpringBoot: migrationsComplete
SpringBoot-->>SpringBoot: finishStartup
ER diagram for sys_i18n_menu and related menu dataerDiagram
SYS_MENU {
bigint id PK
varchar name
varchar path
}
SYS_I18N_MENU {
bigint id PK
bigint creator
bigint editor
timestamp create_time
timestamp update_time
smallint del_flag
int version
bigint tenant_id
bigint dept_id
varchar code
varchar menu
}
SYS_MENU ||--o{ SYS_I18N_MENU : localized_by
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
WalkthroughThis PR systematically replaces Liquibase with Flyway as the database migration framework across the project, updating dependencies, configuration files, migration scripts, documentation, and removing Liquibase-specific tracking tables and changelog structures. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches🧪 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 |
Review Summary by QodoMigrate database migration tool from Liquibase to Flyway
WalkthroughsDescription• Replace Liquibase with Flyway for database migration management • Update Maven dependencies from liquibase-core to flyway-core and flyway-database-postgresql • Migrate database migration scripts from XML changelog format to Flyway SQL naming convention • Update Spring Boot configuration to use Flyway settings instead of Liquibase • Remove Liquibase-specific database tables (databasechangelog, databasechangeloglock) • Add comprehensive Flyway configuration documentation with comparison to Liquibase Diagramflowchart LR
Liquibase["Liquibase<br/>XML Changelogs"] -->|Replace| Flyway["Flyway<br/>SQL Scripts"]
Liquibase -->|Remove Tables| OldTables["databasechangelog<br/>databasechangeloglock"]
Flyway -->|Create Table| NewTable["flyway_schema_history"]
Config["application.yml<br/>Configuration"] -->|Update| FlywayConfig["flyway.locations<br/>baseline-on-migrate"]
Dependencies["pom.xml<br/>Dependencies"] -->|Update| FlywayDeps["flyway-core<br/>flyway-database-postgresql"]
File Changes2. archive/docs/00.二开指南/02.指南/21.Flyway配置.md
|
Code Review by Qodo
1. Destructive Flyway V1 migration
|
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些总体层面的反馈:
- admin 模块和 standalone 模块的 Flyway 迁移脚本是重复的(V1–V3 文件中的 SQL 完全相同);建议抽取公共迁移脚本或复用一个共享模块,以避免将来脚本发生偏差。
- 在共享 SQL 中删除 Liquibase 元数据表(
databasechangelog*)并移除 Liquibase 依赖,前提是假设当前没有任何环境仍依赖它们;请确认所有部署环境都已完全迁移到 Flyway,或者提供一个向后兼容的过渡方案。
面向 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- The Flyway migration scripts for admin and standalone modules are duplicated (V1–V3 files with identical SQL); consider extracting shared migrations or reusing a common module to avoid divergence over time.
- Dropping Liquibase metadata tables (`databasechangelog*`) from the shared SQL and removing Liquibase dependencies assumes no existing environments still rely on them; verify that all deployments are fully migrated to Flyway or provide a backward-compatible transition path.
## Individual Comments
### Comment 1
<location path="laokou-service/laokou-admin/laokou-admin-start/src/main/resources/application.yml" line_range="130-132" />
<code_context>
+ # SQL脚本存放路径,默认是 classpath:db/migration
+ locations: classpath:db/migration
+ # 第一次运行环境是否自动执行基准迁移(当已有数据库表时需开启)
+ baseline-on-migrate: true
+ # 基准版本号,默认为 1
+ baseline-version: 1
</code_context>
<issue_to_address>
**question (bug_risk):** Flyway `baseline-on-migrate` with `baseline-version: 0` may not match the intent for existing schemas starting at V1.
On existing schemas, this setup will cause Flyway to rerun V1+ migrations that have already been applied (e.g., previously via Liquibase), potentially reapplying DDL/data changes. If the existing schema should be treated as the starting point for V1, set `baseline-version` to the version that matches your first migration so Flyway does not re-execute those scripts.
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The Flyway migration scripts for admin and standalone modules are duplicated (V1–V3 files with identical SQL); consider extracting shared migrations or reusing a common module to avoid divergence over time.
- Dropping Liquibase metadata tables (
databasechangelog*) from the shared SQL and removing Liquibase dependencies assumes no existing environments still rely on them; verify that all deployments are fully migrated to Flyway or provide a backward-compatible transition path.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The Flyway migration scripts for admin and standalone modules are duplicated (V1–V3 files with identical SQL); consider extracting shared migrations or reusing a common module to avoid divergence over time.
- Dropping Liquibase metadata tables (`databasechangelog*`) from the shared SQL and removing Liquibase dependencies assumes no existing environments still rely on them; verify that all deployments are fully migrated to Flyway or provide a backward-compatible transition path.
## Individual Comments
### Comment 1
<location path="laokou-service/laokou-admin/laokou-admin-start/src/main/resources/application.yml" line_range="130-132" />
<code_context>
+ # SQL脚本存放路径,默认是 classpath:db/migration
+ locations: classpath:db/migration
+ # 第一次运行环境是否自动执行基准迁移(当已有数据库表时需开启)
+ baseline-on-migrate: true
+ # 基准版本号,默认为 1
+ baseline-version: 1
</code_context>
<issue_to_address>
**question (bug_risk):** Flyway `baseline-on-migrate` with `baseline-version: 0` may not match the intent for existing schemas starting at V1.
On existing schemas, this setup will cause Flyway to rerun V1+ migrations that have already been applied (e.g., previously via Liquibase), potentially reapplying DDL/data changes. If the existing schema should be treated as the starting point for V1, set `baseline-version` to the version that matches your first migration so Flyway does not re-execute those scripts.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| baseline-on-migrate: true | ||
| baseline-version: 0 | ||
| validate-on-migrate: true |
There was a problem hiding this comment.
question (bug_risk): Flyway baseline-on-migrate 配合 baseline-version: 0 时,可能与以 V1 为起点的现有 schema 的设计意图不一致。
在已有 schema 的情况下,这种配置会让 Flyway 重新执行那些已经应用过的 V1+ 迁移(例如此前通过 Liquibase 执行的),从而可能重复执行 DDL/数据变更。如果现有 schema 应被视为从 V1 开始的基准状态,请将 baseline-version 设置为与你第一个迁移脚本相匹配的版本号,以避免 Flyway 再次执行这些脚本。
Original comment in English
question (bug_risk): Flyway baseline-on-migrate with baseline-version: 0 may not match the intent for existing schemas starting at V1.
On existing schemas, this setup will cause Flyway to rerun V1+ migrations that have already been applied (e.g., previously via Liquibase), potentially reapplying DDL/data changes. If the existing schema should be treated as the starting point for V1, set baseline-version to the version that matches your first migration so Flyway does not re-execute those scripts.
| DROP TABLE IF EXISTS "public"."sys_i18n_menu"; | ||
| CREATE TABLE "public"."sys_i18n_menu" ( |
There was a problem hiding this comment.
1. Destructive flyway v1 migration 🐞 Bug ⛯ Reliability
V1_202603092010__create_i18n_menu.sql drops public.sys_i18n_menu, so the first Flyway run can delete an existing table (and its data) instead of performing an additive migration. With baseline-on-migrate: true and baseline-version: 0, Flyway will still run V1+ on non-empty schemas, making this data loss likely during upgrades.
Agent Prompt
## Issue description
The Flyway V1 migration drops `public.sys_i18n_menu`, which can delete existing data when Flyway runs for the first time on a non-empty schema.
## Issue Context
Flyway is enabled with `baseline-on-migrate: true` and `baseline-version: 0`, which will allow Flyway to start tracking an existing schema and then execute V1+ migrations. The repo also includes an initialization script that already creates and seeds `sys_i18n_menu`, so it’s plausible that environments already contain data in this table.
## Fix Focus Areas
- laokou-service/laokou-admin/laokou-admin-start/src/main/resources/db/migration/V1_202603092010__create_i18n_menu.sql[1-14]
- laokou-service/laokou-admin/laokou-admin-start/src/main/resources/application.yml[127-132]
- laokou-service/laokou-standalone/laokou-standalone-admin/laokou-standalone-admin-start/src/main/resources/db/migration/V1_202603092010__create_i18n_menu.sql[1-34]
- laokou-service/laokou-standalone/laokou-standalone-admin/laokou-standalone-admin-start/src/main/resources/application.yml[129-134]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| DROP TABLE IF EXISTS "public"."sys_i18n_menu"; | ||
| CREATE TABLE "public"."sys_i18n_menu" ( | ||
| "id" int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY, |
There was a problem hiding this comment.
2. I18nmenu schema mismatch 🐞 Bug ✓ Correctness
The Flyway migrations create/seed table sys_i18n_menu with columns like code and menu, but the I18nMenu persistence layer queries sys_i18n_message and maps zhMessage/enMessage fields. This mismatch means the seeded data won’t be read by the application and can also cause runtime SQL errors if sys_i18n_message (or its expected columns) doesn’t exist.
Agent Prompt
## Issue description
Flyway migrations create/seed `sys_i18n_menu(code, menu, ...)`, but the application reads from `sys_i18n_message` and expects `zhMessage`/`enMessage` fields, so the new schema/data won’t be used and queries can fail.
## Issue Context
The migration scripts added/modified in this PR appear to be introducing an “国际化菜单” table and seed rows. However, the `I18nMenuDO` and `I18nMenuMapper.xml` are still hard-coded to `sys_i18n_message`, and the domain model contains `zhMessage/enMessage` rather than `menu`.
## Fix Focus Areas
- laokou-service/laokou-admin/laokou-admin-start/src/main/resources/db/migration/V1_202603092010__create_i18n_menu.sql[1-14]
- laokou-service/laokou-admin/laokou-admin-start/src/main/resources/db/migration/V2_202603092010__insert_i18n_menu.sql[1-29]
- laokou-service/laokou-admin/laokou-admin-infrastructure/src/main/java/org/laokou/admin/i18nMenu/gatewayimpl/database/dataobject/I18nMenuDO.java[29-47]
- laokou-service/laokou-admin/laokou-admin-infrastructure/src/main/resources/mapper/i18nMenu/I18nMenuMapper.xml[23-42]
- laokou-service/laokou-admin/laokou-admin-domain/src/main/java/org/laokou/admin/i18nMenu/model/I18nMenuE.java[27-49]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5844 +/- ##
=========================================
Coverage 58.32% 58.32%
Complexity 1144 1144
=========================================
Files 270 270
Lines 5358 5358
Branches 339 339
=========================================
Hits 3125 3125
Misses 2057 2057
Partials 176 176 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|


Summary by Sourcery
将数据库变更管理从 Liquibase 迁移到 Flyway,覆盖所有管理服务,并更新相关的 SQL 迁移脚本和配置。
增强内容:
文档:
Original summary in English
Summary by Sourcery
Migrate database change management from Liquibase to Flyway across the admin services and update related SQL migrations and configuration.
Enhancements:
Documentation:
Summary by CodeRabbit
Documentation
Chores