Skip to content

Commit 0099a9b

Browse files
committed
feat: migration now supports configs aswell
1 parent 5e27367 commit 0099a9b

4 files changed

Lines changed: 185 additions & 759 deletions

File tree

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package dev.objz.commandbridge.scripting.migration;
22

33
import java.util.List;
4+
import java.util.Map;
45

56
/**
67
* Represents a single version-to-version migration step loaded from a
7-
* resource file (e.g. {@code migrations/2-3.yml})
8+
* resource file (e.g. {@code migrations/2-3.yml}).
9+
* <p>
10+
* Rules are grouped by section {@code "scripts"}, {@code "configs"}.
811
*
9-
* @param from the source version
10-
* @param to the target version
11-
* @param rules the list of rules to apply
12+
* @param from the source version
13+
* @param to the target version
14+
* @param sections map of section name to its list of migration rules
1215
*/
13-
public record MigrationStep(int from, int to, List<MigrationRule> rules) {
16+
public record MigrationStep(int from, int to, Map<String, List<MigrationRule>> sections) {
1417

1518
public MigrationStep {
16-
rules = List.copyOf(rules);
19+
sections = Map.copyOf(sections);
20+
}
21+
22+
public List<MigrationRule> rules(String section) {
23+
return sections.getOrDefault(section, List.of());
1724
}
1825
}

0 commit comments

Comments
 (0)