@@ -19,8 +19,13 @@ const (
1919// MigrationMap defines a mapping from a version to a transformation plan.
2020type MigrationMap map [string ]func (from * tomledit.Document , to string ) transform.Plan
2121
22+ // loadDestConfigFile is the function signature to load the destination version
23+ // configuration toml file.
24+ type loadDestConfigFile func (to , planType string ) (* tomledit.Document , error )
25+
2226var Migrations = MigrationMap {
2327 "v0.45" : NoPlan , // Confix supports only the current supported SDK version. So we do not support v0.44 -> v0.45.
28+ << << << < HEAD
2429 "v0.46" : PlanBuilder ,
2530 "v0.47" : PlanBuilder ,
2631 "v0.50" : PlanBuilder ,
@@ -33,6 +38,48 @@ func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
3338 deletedSections := map [string ]bool {}
3439
3540 target , err := LoadLocalConfig (to )
41+ == == == =
42+ "v0.46" : defaultPlanBuilder ,
43+ "v0.47" : defaultPlanBuilder ,
44+ "v0.50" : defaultPlanBuilder ,
45+ "v0.52" : defaultPlanBuilder ,
46+ "v2" : V2PlanBuilder ,
47+ // "v0.xx.x": defaultPlanBuilder, // add specific migration in case of configuration changes in minor versions
48+ }
49+
50+ type v2KeyChangesMap map [string ][]string
51+
52+ // list all the keys which are need to be modified in v2
53+ var v2KeyChanges = v2KeyChangesMap {
54+ "min-retain-blocks" : []string {"comet.min-retain-blocks" },
55+ "index-events" : []string {"comet.index-events" },
56+ "halt-height" : []string {"comet.halt-height" },
57+ "halt-time" : []string {"comet.halt-time" },
58+ "app-db-backend" : []string {"store.app-db-backend" },
59+ "pruning-keep-recent" : []string {
60+ "store.options.ss-pruning-option.keep-recent" ,
61+ "store.options.sc-pruning-option.keep-recent" ,
62+ },
63+ "pruning-interval" : []string {
64+ "store.options.ss-pruning-option.interval" ,
65+ "store.options.sc-pruning-option.interval" ,
66+ },
67+ "iavl-cache-size" : []string {"store.options.iavl-config.cache-size" },
68+ "iavl-disable-fastnode" : []string {"store.options.iavl-config.skip-fast-storage-upgrade" },
69+ // Add other key mappings as needed
70+ }
71+
72+ func defaultPlanBuilder (from * tomledit .Document , to , planType string ) (transform .Plan , * tomledit .Document ) {
73+ return PlanBuilder (from , to , planType , LoadLocalConfig )
74+ }
75+
76+ // PlanBuilder is a function that returns a transformation plan for a given diff between two files.
77+ func PlanBuilder (from * tomledit .Document , to , planType string , loadFn loadDestConfigFile ) (transform .Plan , * tomledit .Document ) {
78+ plan := transform.Plan {}
79+ deletedSections := map [string ]bool {}
80+
81+ target , err := loadFn (to , planType )
82+ >> >> >> > 1 d7f891ea (feat (confix ): allow customization of migration plan (#21202 ))
3683 if err != nil {
3784 panic (fmt .Errorf ("failed to parse file: %w. This file should have been valid" , err ))
3885 }
0 commit comments