Small fix

This commit is contained in:
edwardro22
2017-09-17 23:53:15 +00:00
parent ce60ae1d46
commit ba96c5cb9c
4 changed files with 12 additions and 42 deletions

View File

@@ -74,7 +74,7 @@ var (
oldDBDataEncoding = flag.String("old_dbdata_encoding", "", "The encoding used to store object data in strings")
dryRun = flag.Bool("dry_run", false, "When true will not save loaded data to dataDb but just parse it for consistency and errors.")
verbose = flag.Bool("verbose", false, "Enable detailed verbose logging output")
stats = flag.Bool("stats", false, "Generates statsistics about given data.")
stats = flag.Bool("stats", false, "Generates statsistics about migrated data.")
)
func main() {

View File

@@ -4,7 +4,7 @@ but it only migrate CDRs where the duration is > 0.
If you need CDRs also with duration is = 0 you can make the appropriate change in the line beginning WHERE cdrs_primary.usage
Also the script will process 10,000 CDRs before committing to save system resources
especially in systems where they are millions of CDRs to be migrated
You can increase or lower the value of step in the line after BEGIN below.P
You can increase or lower the value of step in the line after BEGIN below.
You have to use 'CALL cgrates.migration();' to execute the script. If named other then default use that database name.
*/

View File

@@ -88,37 +88,6 @@ func (m *Migrator) migrateActionTriggers() (err error) {
}
}
return
}
func (m *Migrator) dryRunActionTriggers() (err error) {
var v1ACTs *v1ActionTriggers
var acts engine.ActionTriggers
for {
v1ACTs, err = m.oldDataDB.getV1ActionTriggers()
if err != nil && err != utils.ErrNoMoreData {
return err
}
if err == utils.ErrNoMoreData {
break
}
if *v1ACTs != nil {
for _, v1ac := range *v1ACTs {
act := v1ac.AsActionTrigger()
acts = append(acts, act)
}
}
}
// All done, update version wtih current one
vrs := engine.Versions{utils.ActionTriggers: engine.CurrentDataDBVersions()[utils.ActionTriggers]}
if err = m.dataDB.SetVersions(vrs, false); err != nil {
return utils.NewCGRError(utils.Migrator,
utils.ServerErrorCaps,
err.Error(),
fmt.Sprintf("error: <%s> when updating ActionTriggers version into DataDB", err.Error()))
}
return
}
func (v1Act v1ActionTrigger) AsActionTrigger() (at *engine.ActionTrigger) {

View File

@@ -108,15 +108,16 @@ func (m *Migrator) migrateCostDetails() (err error) {
fmt.Sprintf("<Migrator> Error: <%s> updating CDR with id <%d> into StorDB", err.Error(), id))
continue
}
}
m.stats[utils.COST_DETAILS] += 1
// All done, update version wtih current one
vrs = engine.Versions{utils.COST_DETAILS: engine.CurrentStorDBVersions()[utils.COST_DETAILS]}
if err := m.storDB.SetVersions(vrs, false); err != nil {
return utils.NewCGRError(utils.Migrator,
utils.ServerErrorCaps,
err.Error(),
fmt.Sprintf("error: <%s> when updating CostDetails version into StorDB", err.Error()))
m.stats[utils.COST_DETAILS] += 1
// All done, update version wtih current one
vrs = engine.Versions{utils.COST_DETAILS: engine.CurrentStorDBVersions()[utils.COST_DETAILS]}
if err := m.storDB.SetVersions(vrs, false); err != nil {
return utils.NewCGRError(utils.Migrator,
utils.ServerErrorCaps,
err.Error(),
fmt.Sprintf("error: <%s> when updating CostDetails version into StorDB", err.Error()))
}
}
}
return