configmigrate: revert

This commit is contained in:
Dimitry Kolyshev 2024-07-31 15:09:18 +03:00
parent a036638c05
commit 787b5d4039
4 changed files with 1 additions and 109 deletions

View file

@ -2,4 +2,4 @@
package configmigrate
// LastSchemaVersion is the most recent schema version.
const LastSchemaVersion uint = 29
const LastSchemaVersion uint = 28

View file

@ -1728,63 +1728,3 @@ func TestUpgradeSchema27to28(t *testing.T) {
})
}
}
func TestUpgradeSchema28to29(t *testing.T) {
const newSchemaVer = 29
testCases := []struct {
in yobj
want yobj
name string
}{{
name: "empty",
in: yobj{},
want: yobj{
"schema_version": newSchemaVer,
},
}, {
name: "disabled",
in: yobj{
"dns": yobj{
"safe_search": yobj{
"enabled": false,
},
},
},
want: yobj{
"schema_version": newSchemaVer,
"dns": yobj{
"safe_search": yobj{
"enabled": false,
},
},
},
}, {
name: "enabled",
in: yobj{
"dns": yobj{
"safe_search": yobj{
"enabled": true,
},
},
},
want: yobj{
"schema_version": newSchemaVer,
"dns": yobj{
"safe_search": yobj{
"ecosia": true,
"enabled": true,
},
},
},
}}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := migrateTo29(tc.in)
require.NoError(t, err)
assert.Equal(t, tc.want, tc.in)
})
}
}

View file

@ -120,7 +120,6 @@ func (m *Migrator) upgradeConfigSchema(current, target uint, diskConf yobj) (err
25: migrateTo26,
26: migrateTo27,
27: migrateTo28,
28: migrateTo29,
}
for i, migrate := range upgrades[current:target] {

View file

@ -1,47 +0,0 @@
package configmigrate
// migrateTo29 performs the following changes:
//
// # BEFORE:
// 'dns':
// 'safe_search':
// 'enabled': true
// 'bing': true
// 'duckduckgo': true
// 'google': true
// 'pixabay': true
// 'yandex': true
// 'youtube': true
// # …
// # …
//
// # AFTER:
// 'dns':
// 'safe_search':
// 'enabled': true
// 'bing': true
// 'duckduckgo': true
// 'ecosia': true
// 'google': true
// 'pixabay': true
// 'yandex': true
// 'youtube': true
// # …
// # …
func migrateTo29(diskConf yobj) (err error) {
diskConf["schema_version"] = 29
dns, ok, err := fieldVal[yobj](diskConf, "dns")
if !ok {
return err
}
safeSearch, _, _ := fieldVal[yobj](dns, "safe_search")
if safeSearch["enabled"] == true {
safeSearch["ecosia"] = true
}
dns["safe_search"] = safeSearch
return nil
}