Migrating

Migrating from CGRateS

Exporting CDRs and rate profiles, and what maps to what.

5 min read

Exporting the CDRs

CGRateS can export rated CDRs to CSV from the CDRe subsystem or straight out of the cdrs table. Either is fine — we re-rate against your plans rather than trusting the amount, so a rated export and a raw one produce the same result.

cgr-console 'cdrs_export Type="csv" ExportPath="/tmp/cdrs" \
  Filters=["*gte:~*req.AnswerTime:2024-01-01T00:00:00Z"]'
CGRateS fieldMaps toNotes
OriginIDIdentifierStable across exports, which is what makes re-imports safe.
AnswerTimeWhenUse AnswerTime, not SetupTime — unanswered calls are not billable.
AccountWhoOr Subject, if that is what you bill against.
UsageHow muchExports as a duration string; convert to seconds before importing.
DestinationTo whereWhat the tariff matches on.
Usage exports as a Go duration ("1m30s"), not a number. Convert it to seconds in the export or with one pass over the file — the importer needs a number and will reject the row rather than interpret it.

Rate profiles become plan versions

A CGRateS RatingProfile with an ActivationTime is the same idea as a plan version with an effective_from. Export one plan version per activation time and the historical rating comes out identical.

DestinationRates map to tariff lines: the destination prefix becomes match_key, RateIncrement becomes increment, and ConnectFee is a minimum. Rate groups with more than one tier within a call are the one thing that does not map — split them into separate plan lines, or tell us and we will look at it.