From ba96c5cb9ca93439f1b8faf8549dbf13f0d02cc3 Mon Sep 17 00:00:00 2001 From: edwardro22 Date: Sun, 17 Sep 2017 23:53:15 +0000 Subject: [PATCH] Small fix --- cmd/cgr-migrator/cgr-migrator.go | 2 +- data/storage/migrator/mysql_cdr_migration.sql | 2 +- migrator/action_trigger.go | 31 ------------------- migrator/costdetails.go | 19 ++++++------ 4 files changed, 12 insertions(+), 42 deletions(-) diff --git a/cmd/cgr-migrator/cgr-migrator.go b/cmd/cgr-migrator/cgr-migrator.go index aa88b582f..73febb848 100755 --- a/cmd/cgr-migrator/cgr-migrator.go +++ b/cmd/cgr-migrator/cgr-migrator.go @@ -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() { diff --git a/data/storage/migrator/mysql_cdr_migration.sql b/data/storage/migrator/mysql_cdr_migration.sql index 7a7e0d0a3..3740af1ed 100755 --- a/data/storage/migrator/mysql_cdr_migration.sql +++ b/data/storage/migrator/mysql_cdr_migration.sql @@ -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. */ diff --git a/migrator/action_trigger.go b/migrator/action_trigger.go index 34b8a8359..f227cefd4 100644 --- a/migrator/action_trigger.go +++ b/migrator/action_trigger.go @@ -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) { diff --git a/migrator/costdetails.go b/migrator/costdetails.go index a073dffaf..245c84f5c 100644 --- a/migrator/costdetails.go +++ b/migrator/costdetails.go @@ -108,15 +108,16 @@ func (m *Migrator) migrateCostDetails() (err error) { fmt.Sprintf(" 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