From f58a07a029ed84205a43dc77df3fd46353d8ce2c Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 27 Dec 2015 11:38:59 +0100 Subject: [PATCH] Adding TBLSMCosts model --- data/storage/mysql/create_cdrs_tables.sql | 14 ++++++++++++++ data/storage/postgres/create_cdrs_tables.sql | 15 +++++++++++++++ engine/models.go | 10 ++++++++++ 3 files changed, 39 insertions(+) diff --git a/data/storage/mysql/create_cdrs_tables.sql b/data/storage/mysql/create_cdrs_tables.sql index 799d05edf..3f5e0269d 100644 --- a/data/storage/mysql/create_cdrs_tables.sql +++ b/data/storage/mysql/create_cdrs_tables.sql @@ -35,3 +35,17 @@ CREATE TABLE cdrs ( PRIMARY KEY (id), UNIQUE KEY cdrrun (cgrid, run_id) ); + +DROP TABLE IF EXISTS sm_costs; +CREATE TABLE sm_costs ( + id int(11) NOT NULL AUTO_INCREMENT, + cgrid char(40) NOT NULL, + run_id varchar(64) NOT NULL, + cost_source varchar(64) NOT NULL, + cost_details text, + created_at TIMESTAMP, + deleted_at TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY costid (cgrid,run_id), + KEY deleted_at_idx (deleted_at) +); diff --git a/data/storage/postgres/create_cdrs_tables.sql b/data/storage/postgres/create_cdrs_tables.sql index d76ab282b..3d386ec7e 100644 --- a/data/storage/postgres/create_cdrs_tables.sql +++ b/data/storage/postgres/create_cdrs_tables.sql @@ -37,3 +37,18 @@ CREATE TABLE cdrs ( ; DROP INDEX IF EXISTS deleted_at_cp_idx; CREATE INDEX deleted_at_cp_idx ON cdrs_primary (deleted_at); + + +DROP TABLE IF EXISTS sm_costs; +CREATE TABLE sm_costs ( + id SERIAL PRIMARY KEY, + cgrid CHAR(40) NOT NULL, + run_id VARCHAR(64) NOT NULL, + cost_source VARCHAR(64) NOT NULL, + cost_details jsonb, + created_at TIMESTAMP, + deleted_at TIMESTAMP, + UNIQUE (cgrid, run_id) +); +DROP INDEX IF EXISTS deleted_at_smcost_idx; +CREATE INDEX deleted_at_smcost_idx ON sm_costs (deleted_at); diff --git a/engine/models.go b/engine/models.go index 8235ab0e3..1740db60a 100644 --- a/engine/models.go +++ b/engine/models.go @@ -426,3 +426,13 @@ type TBLCDRs struct { func (t TBLCDRs) TableName() string { return utils.TBL_CDRS } + +type TBLSMCosts struct { + ID int64 + Cgrid string + RunID string + CostSource string + CostDetails string + CreatedAt time.Time + DeletedAt time.Time +}