Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-475 Add config migrations #475

Closed
wants to merge 7 commits into from
Closed

GH-475 Add config migrations #475

wants to merge 7 commits into from

Conversation

vLuckyyy
Copy link
Member

@vLuckyyy vLuckyyy commented Aug 23, 2023

I plan to merge this only AFTER the first release.

This pull request introduces a migration system within the configuration. The purpose of this system is to facilitate easy key changes in the configuration while maintaining compatibility with older data.

Here's an example of a migration:

package com.eternalcode.core.configuration.migration.impl;

import com.eternalcode.core.configuration.migration.AbstractMigration;

import static com.eternalcode.core.configuration.migration.MigrationStep.move;

public class PC1 extends AbstractMigration {

    public PC1() {
        super("Cosmetic change for number of lines to clear.",
            move("chat.linesToClear", "chat.numberOfLinesToClear"));
    }

    @Override
    public int migrationNumber() {
        return 1;
    }

    @Override
    public String file() {
        return "config.yml";
    }
}

In the above example, "PC" stands for "PluginConfiguration," and "1" is the migration number. The same convention will be applied to other migrations as well.

It's worth noting that the migration system itself is in its early development stages and will likely require numerous refinements to achieve optimal functionality.

2023-08-23.13-12-04.mov

@vLuckyyy vLuckyyy changed the title Config migrations [WIP] Config migrations Aug 23, 2023
@vLuckyyy vLuckyyy added the 🆕 feature New feature or request label Aug 23, 2023
@vLuckyyy vLuckyyy changed the title [WIP] Config migrations Add config migrations Aug 23, 2023
@vLuckyyy vLuckyyy changed the title Add config migrations GH-475 Add config migrations Aug 23, 2023
@vLuckyyy vLuckyyy marked this pull request as ready for review August 23, 2023 11:17
Copy link
Member

@Jakubk15 Jakubk15 left a comment

Choose a reason for hiding this comment

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

Looks good to me overall


import static com.eternalcode.core.configuration.migration.MigrationStep.move;

public class PC1 extends AbstractMigration {
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that this name isn’t too generic? We should use something more understandable.

}

@Override
public int migrationNumber() {
Copy link
Member

Choose a reason for hiding this comment

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

You can base order of migrations on list order. #475 (comment)


public class MigrateFactory {

private final List<Migration> migrations;
Copy link
Member

Choose a reason for hiding this comment

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

I mean this list ^

@vLuckyyy
Copy link
Member Author

I want migrate to okaeri-configs for built-in migrations and better yaml parsing.

@vLuckyyy vLuckyyy closed this Oct 20, 2023
@vLuckyyy vLuckyyy deleted the config-migrations branch October 20, 2023 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants