mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 16:42:38 +01:00
add a schema change
This commit is contained in:
parent
1e572e8458
commit
898f8aad07
@ -24,7 +24,7 @@ const (
|
||||
// 'version' of the database schema
|
||||
keySchemaVersion = "db.version"
|
||||
// latest schema of the db
|
||||
latestDbSchema = "14"
|
||||
latestDbSchema = "15"
|
||||
|
||||
keyCloakSecret = "crypto.cloak_secret"
|
||||
)
|
||||
@ -792,6 +792,26 @@ func schemaChangeV13ToV14(config *Config, tx *buntdb.Tx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// #1327: delete any invalid klines
|
||||
func schemaChangeV14ToV15(config *Config, tx *buntdb.Tx) error {
|
||||
prefix := "bans.klinev2 "
|
||||
var keys []string
|
||||
tx.AscendGreaterOrEqual("", prefix, func(key, value string) bool {
|
||||
if !strings.HasPrefix(key, prefix) {
|
||||
return false
|
||||
}
|
||||
if key != strings.TrimSpace(key) {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
return true
|
||||
})
|
||||
// don't bother trying to fix these up
|
||||
for _, key := range keys {
|
||||
tx.Delete(key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
allChanges := []SchemaChange{
|
||||
{
|
||||
@ -859,6 +879,11 @@ func init() {
|
||||
TargetVersion: "14",
|
||||
Changer: schemaChangeV13ToV14,
|
||||
},
|
||||
{
|
||||
InitialVersion: "14",
|
||||
TargetVersion: "15",
|
||||
Changer: schemaChangeV14ToV15,
|
||||
},
|
||||
}
|
||||
|
||||
// build the index
|
||||
|
Loading…
Reference in New Issue
Block a user