Pull request 2111: 6545-schema-version
Updates #6545. Squashed commit of the following: commit b1969128a99ff21c97feb4e7805b4b8133d7122f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Dec 15 20:04:37 2023 +0300 home: fix import commit 872ccea1491a8da76cc24db79247438d0ce4d256 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Dec 15 20:01:15 2023 +0300 all: output schema version
This commit is contained in:
52
internal/configmigrate/v15.go
Normal file
52
internal/configmigrate/v15.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package configmigrate
|
||||
|
||||
// migrateTo15 performs the following changes:
|
||||
//
|
||||
// # BEFORE:
|
||||
// 'schema_version': 14
|
||||
// 'dns':
|
||||
// # …
|
||||
// 'querylog_enabled': true
|
||||
// 'querylog_file_enabled': true
|
||||
// 'querylog_interval': '2160h'
|
||||
// 'querylog_size_memory': 1000
|
||||
// 'querylog':
|
||||
// # …
|
||||
// # …
|
||||
//
|
||||
// # AFTER:
|
||||
// 'schema_version': 15
|
||||
// 'dns':
|
||||
// # …
|
||||
// 'querylog':
|
||||
// 'enabled': true
|
||||
// 'file_enabled': true
|
||||
// 'interval': '2160h'
|
||||
// 'size_memory': 1000
|
||||
// 'ignored': []
|
||||
// # …
|
||||
// # …
|
||||
func migrateTo15(diskConf yobj) (err error) {
|
||||
diskConf["schema_version"] = 15
|
||||
|
||||
dns, ok, err := fieldVal[yobj](diskConf, "dns")
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
|
||||
qlog := map[string]any{
|
||||
"ignored": yarr{},
|
||||
"enabled": true,
|
||||
"file_enabled": true,
|
||||
"interval": "2160h",
|
||||
"size_memory": 1000,
|
||||
}
|
||||
diskConf["querylog"] = qlog
|
||||
|
||||
return coalesceError(
|
||||
moveVal[bool](dns, qlog, "querylog_enabled", "enabled"),
|
||||
moveVal[bool](dns, qlog, "querylog_file_enabled", "file_enabled"),
|
||||
moveVal[any](dns, qlog, "querylog_interval", "interval"),
|
||||
moveVal[int](dns, qlog, "querylog_size_memory", "size_memory"),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user