Test fixes for multiple cdrc, CheckVersion taking now db as input, InitDataDb saving also version

This commit is contained in:
DanB
2016-06-01 18:42:45 +02:00
committed by Razvan Crainea
parent 0f380ec2bc
commit dd94117e5d
5 changed files with 22 additions and 19 deletions

View File

@@ -48,6 +48,7 @@ func InitDataDb(cfg *config.CGRConfig) error {
}
}
ratingDb.CacheRatingAll()
CheckVersion(accountDb) // Write version before starting
return nil
}

View File

@@ -7,13 +7,16 @@ import (
"github.com/cgrates/cgrates/utils"
)
func CheckVersion() error {
func CheckVersion(acntDB AccountingStorage) error {
// get current db version
dbVersion, err := accountingStorage.GetStructVersion()
if acntDB == nil {
acntDB = accountingStorage
}
dbVersion, err := acntDB.GetStructVersion()
if err != nil {
if lhList, err := accountingStorage.GetLoadHistory(1, true); err != nil || len(lhList) == 0 {
if lhList, err := acntDB.GetLoadHistory(1, true); err != nil || len(lhList) == 0 {
// no data, write version
if err := accountingStorage.SetStructVersion(CurrentVersion); err != nil {
if err := acntDB.SetStructVersion(CurrentVersion); err != nil {
utils.Logger.Warning(fmt.Sprintf("Could not write current version to db: %v", err))
}
} else {