|
@@ -24,7 +24,7 @@ const (
|
24
|
24
|
// 'version' of the database schema
|
25
|
25
|
keySchemaVersion = "db.version"
|
26
|
26
|
// latest schema of the db
|
27
|
|
- latestDbSchema = "15"
|
|
27
|
+ latestDbSchema = "16"
|
28
|
28
|
|
29
|
29
|
keyCloakSecret = "crypto.cloak_secret"
|
30
|
30
|
)
|
|
@@ -812,6 +812,29 @@ func schemaChangeV14ToV15(config *Config, tx *buntdb.Tx) error {
|
812
|
812
|
return nil
|
813
|
813
|
}
|
814
|
814
|
|
|
815
|
+// #1330: delete any stale realname records
|
|
816
|
+func schemaChangeV15ToV16(config *Config, tx *buntdb.Tx) error {
|
|
817
|
+ prefix := "account.realname "
|
|
818
|
+ verifiedPrefix := "account.verified "
|
|
819
|
+ var keys []string
|
|
820
|
+ tx.AscendGreaterOrEqual("", prefix, func(key, value string) bool {
|
|
821
|
+ if !strings.HasPrefix(key, prefix) {
|
|
822
|
+ return false
|
|
823
|
+ }
|
|
824
|
+ acct := strings.TrimPrefix(key, prefix)
|
|
825
|
+ verifiedKey := verifiedPrefix + acct
|
|
826
|
+ _, verifiedErr := tx.Get(verifiedKey)
|
|
827
|
+ if verifiedErr != nil {
|
|
828
|
+ keys = append(keys, key)
|
|
829
|
+ }
|
|
830
|
+ return true
|
|
831
|
+ })
|
|
832
|
+ for _, key := range keys {
|
|
833
|
+ tx.Delete(key)
|
|
834
|
+ }
|
|
835
|
+ return nil
|
|
836
|
+}
|
|
837
|
+
|
815
|
838
|
func init() {
|
816
|
839
|
allChanges := []SchemaChange{
|
817
|
840
|
{
|
|
@@ -884,6 +907,11 @@ func init() {
|
884
|
907
|
TargetVersion: "15",
|
885
|
908
|
Changer: schemaChangeV14ToV15,
|
886
|
909
|
},
|
|
910
|
+ {
|
|
911
|
+ InitialVersion: "15",
|
|
912
|
+ TargetVersion: "16",
|
|
913
|
+ Changer: schemaChangeV15ToV16,
|
|
914
|
+ },
|
887
|
915
|
}
|
888
|
916
|
|
889
|
917
|
// build the index
|