Skip to content

Conversation

@gtn1024
Copy link
Contributor

@gtn1024 gtn1024 commented Oct 23, 2025

使用方式:

@Startup
class FooMigrate extends AbstractMigration {
    @Inject
    FooController fooController;

    @Override
    public List<MigrateStep> getMigrateSteps() {
        return List.of(
            new MigrateStep(1, () -> {
                PageResult pages = fooController.view(null, null, true, null);
                pages.getList().forEach((item) -> {
                    Map map = (Map) item;
                    Map newMap = new HashMap((Map) item);
                    newMap.remove("id");
                    newMap.put("i_age", (Integer) map.get("i_age") + 10);
                    fooController.update((String) map.get("id"), newMap);
                });
            }),
            new MigrateStep(2, () -> {
                fooController.create(Map.of(
                    "id", "4",
                    "v_name", "赵六",
                    "i_age", 30
                ));
            }),
        );
    }

    @Override
    public String getAlias() {
        return "foo";
    }
}

Copilot AI review requested due to automatic review settings October 23, 2025 13:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a migration framework to support database versioning and data migration tasks. The framework allows developers to define migration steps that execute sequentially based on version numbers, with automatic tracking of completed migrations.

Key changes:

  • Added a new muyun-migration module with core migration infrastructure
  • Implemented version tracking through a dedicated migration.version table
  • Created test coverage demonstrating migration execution with out-of-order step definitions

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
settings.gradle.kts Registered the new muyun-migration module
muyun-migration/build.gradle.kts Defined dependencies for the migration module
MigrationController.java Created controller to manage migration version tracking
MigrateAction.java Defined functional interface for migration actions
MigrateStep.java Implemented migration step record with version validation
AbstractMigration.java Provided base class for implementing migrations with automatic execution
TestMigration.java Added comprehensive tests for migration functionality
muyun-boot/build.gradle.kts Added migration module dependency to the boot module

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +80 to +81
Map map = (Map) item;
Map newMap = new HashMap((Map) item);
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw types Map and HashMap are used without generic parameters. Consider using Map<String, Object> and HashMap<> for type safety and to avoid potential ClassCastException at runtime.

Copilot uses AI. Check for mistakes.

@ApplicationScoped
class FooController extends BaseScaffold {
public static final List<Map> initData = List.of(
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw type Map is used without generic parameters. Consider using List<Map<String, Object>> for type safety.

Suggested change
public static final List<Map> initData = List.of(
public static final List<Map<String, Object>> initData = List.of(

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants