|
@@ -9,6 +9,7 @@ import (
|
9
|
9
|
"fmt"
|
10
|
10
|
"log"
|
11
|
11
|
"os"
|
|
12
|
+ "strconv"
|
12
|
13
|
"strings"
|
13
|
14
|
"time"
|
14
|
15
|
|
|
@@ -22,7 +23,7 @@ const (
|
22
|
23
|
// 'version' of the database schema
|
23
|
24
|
keySchemaVersion = "db.version"
|
24
|
25
|
// latest schema of the db
|
25
|
|
- latestDbSchema = "9"
|
|
26
|
+ latestDbSchema = "10"
|
26
|
27
|
)
|
27
|
28
|
|
28
|
29
|
type SchemaChanger func(*Config, *buntdb.Tx) error
|
|
@@ -594,6 +595,32 @@ func schemaChangeV8ToV9(config *Config, tx *buntdb.Tx) error {
|
594
|
595
|
return nil
|
595
|
596
|
}
|
596
|
597
|
|
|
598
|
+// #836: account registration time at nanosecond resolution
|
|
599
|
+// (mostly to simplify testing)
|
|
600
|
+func schemaChangeV9ToV10(config *Config, tx *buntdb.Tx) error {
|
|
601
|
+ prefix := "account.registered.time "
|
|
602
|
+ var accounts, times []string
|
|
603
|
+ tx.AscendGreaterOrEqual("", prefix, func(key, value string) bool {
|
|
604
|
+ if !strings.HasPrefix(key, prefix) {
|
|
605
|
+ return false
|
|
606
|
+ }
|
|
607
|
+ account := strings.TrimPrefix(key, prefix)
|
|
608
|
+ accounts = append(accounts, account)
|
|
609
|
+ times = append(times, value)
|
|
610
|
+ return true
|
|
611
|
+ })
|
|
612
|
+ for i, account := range accounts {
|
|
613
|
+ time, err := strconv.ParseInt(times[i], 10, 64)
|
|
614
|
+ if err != nil {
|
|
615
|
+ log.Printf("corrupt registration time entry for %s: %v\n", account, err)
|
|
616
|
+ continue
|
|
617
|
+ }
|
|
618
|
+ time = time * 1000000000
|
|
619
|
+ tx.Set(prefix+account, strconv.FormatInt(time, 10), nil)
|
|
620
|
+ }
|
|
621
|
+ return nil
|
|
622
|
+}
|
|
623
|
+
|
597
|
624
|
func init() {
|
598
|
625
|
allChanges := []SchemaChange{
|
599
|
626
|
{
|
|
@@ -636,6 +663,11 @@ func init() {
|
636
|
663
|
TargetVersion: "9",
|
637
|
664
|
Changer: schemaChangeV8ToV9,
|
638
|
665
|
},
|
|
666
|
+ {
|
|
667
|
+ InitialVersion: "9",
|
|
668
|
+ TargetVersion: "10",
|
|
669
|
+ Changer: schemaChangeV9ToV10,
|
|
670
|
+ },
|
639
|
671
|
}
|
640
|
672
|
|
641
|
673
|
// build the index
|