Fixed the detection of new schema in versions,fixes #750

This commit is contained in:
edwardro22
2017-09-27 15:47:03 +00:00
committed by Dan Christian Bogos
parent 7143c886bf
commit 7e3821bc94
12 changed files with 203 additions and 52 deletions

View File

@@ -60,6 +60,11 @@ func (self *SQLStorage) Flush(scriptsPath string) (err error) {
if _, err := self.Db.Query(fmt.Sprintf("SELECT 1 FROM %s", utils.TBLCDRs)); err != nil {
return err
}
if err = SetDBVersions(self); err != nil {
return err
}
return nil
}
@@ -97,6 +102,19 @@ func (self *SQLStorage) CreateTablesFromScript(scriptPath string) error {
return nil
}
func (self *SQLStorage) IsDBEmpty() (resp bool, err error) {
tbls := []string{utils.TBLTPTimings, utils.TBLTPDestinations, utils.TBLTPRates, utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRateProfiles,
utils.TBLTPSharedGroups, utils.TBLTPCdrStats, utils.TBLTPLcrs, utils.TBLTPActions, utils.TBLTPActionPlans, utils.TBLTPActionTriggers, utils.TBLTPAccountActions,
utils.TBLTPDerivedChargers, utils.TBLTPAliases, utils.TBLTPUsers, utils.TBLTPResources, utils.TBLTPStats}
for _, tbl := range tbls {
resp = self.db.HasTable(tbl)
if resp != false {
return false, nil
}
}
return true, nil
}
// Return a list with all TPids defined in the system, even if incomplete, isolated in some table.
func (self *SQLStorage) GetTpIds() ([]string, error) {
rows, err := self.Db.Query(