mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Adding automatic timestamp columns to SQL
This commit is contained in:
@@ -21,6 +21,8 @@ CREATE TABLE cdrs_primary (
|
||||
setup_time datetime NOT NULL,
|
||||
answer_time datetime NOT NULL,
|
||||
`usage` DECIMAL(30,9) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY cgrid (cgrid)
|
||||
);
|
||||
@@ -34,6 +36,8 @@ CREATE TABLE cdrs_extra (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
cgrid char(40) NOT NULL,
|
||||
extra_fields text NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY cgrid (cgrid)
|
||||
);
|
||||
@@ -46,7 +50,6 @@ DROP TABLE IF EXISTS cost_details;
|
||||
CREATE TABLE cost_details (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
cost_time datetime NOT NULL,
|
||||
cost_source varchar(64) NOT NULL,
|
||||
cgrid char(40) NOT NULL,
|
||||
runid varchar(64) NOT NULL,
|
||||
tor varchar(16) NOT NULL,
|
||||
@@ -58,6 +61,10 @@ CREATE TABLE cost_details (
|
||||
destination varchar(128) NOT NULL,
|
||||
cost DECIMAL(20,4) NOT NULL,
|
||||
timespans text,
|
||||
cost_source varchar(64) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT 0,
|
||||
deleted_at TIMESTAMP DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `costid` (`cgrid`,`runid`)
|
||||
);
|
||||
@@ -83,6 +90,9 @@ CREATE TABLE `rated_cdrs` (
|
||||
`usage` DECIMAL(30,9) NOT NULL,
|
||||
cost DECIMAL(20,4) DEFAULT NULL,
|
||||
extra_info text,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT 0,
|
||||
deleted_at TIMESTAMP DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `costid` (`cgrid`,`runid`)
|
||||
);
|
||||
@@ -11,6 +11,7 @@ CREATE TABLE `tp_timings` (
|
||||
`month_days` varchar(255) NOT NULL,
|
||||
`week_days` varchar(255) NOT NULL,
|
||||
`time` varchar(16) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_tmid` (`tpid`,`tag`),
|
||||
@@ -27,6 +28,7 @@ CREATE TABLE `tp_destinations` (
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`prefix` varchar(24) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_dstid` (`tpid`,`tag`),
|
||||
@@ -47,6 +49,7 @@ CREATE TABLE `tp_rates` (
|
||||
`rate_unit` varchar(16) NOT NULL,
|
||||
`rate_increment` varchar(16) NOT NULL,
|
||||
`group_interval_start` varchar(16) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_tprate` (`tpid`,`tag`,`group_interval_start`),
|
||||
KEY `tpid` (`tpid`),
|
||||
@@ -66,6 +69,7 @@ CREATE TABLE `tp_destination_rates` (
|
||||
`rates_tag` varchar(64) NOT NULL,
|
||||
`rounding_method` varchar(255) NOT NULL,
|
||||
`rounding_decimals` tinyint(4) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_drid` (`tpid`,`tag`),
|
||||
@@ -84,6 +88,7 @@ CREATE TABLE `tp_rating_plans` (
|
||||
`destrates_tag` varchar(64) NOT NULL,
|
||||
`timing_tag` varchar(64) NOT NULL,
|
||||
`weight` DECIMAL(8,2) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_rpl` (`tpid`,`tag`),
|
||||
@@ -106,6 +111,7 @@ CREATE TABLE `tp_rating_profiles` (
|
||||
`activation_time` varchar(24) NOT NULL,
|
||||
`rating_plan_tag` varchar(64) NOT NULL,
|
||||
`fallback_subjects` varchar(64),
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid_loadid` (`tpid`, `loadid`),
|
||||
UNIQUE KEY `tpid_loadid_tenant_category_dir_subj_atime` (`tpid`,`loadid`, `tenant`,`category`,`direction`,`subject`,`activation_time`)
|
||||
@@ -123,6 +129,7 @@ CREATE TABLE `tp_shared_groups` (
|
||||
`account` varchar(24) NOT NULL,
|
||||
`strategy` varchar(24) NOT NULL,
|
||||
`rating_subject` varchar(24) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_shared_group` (`tpid`,`tag`,`account`,`strategy`,`rating_subject`)
|
||||
@@ -149,6 +156,7 @@ CREATE TABLE `tp_actions` (
|
||||
`balance_weight` DECIMAL(8,2) NOT NULL,
|
||||
`extra_parameters` varchar(256) NOT NULL,
|
||||
`weight` DECIMAL(8,2) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_action` (`tpid`,`tag`,`action`,`balance_type`,`direction`,`expiry_time`,`destination_tag`,`shared_group`,`balance_weight`,`weight`)
|
||||
@@ -166,6 +174,7 @@ CREATE TABLE `tp_action_plans` (
|
||||
`actions_tag` varchar(64) NOT NULL,
|
||||
`timing_tag` varchar(64) NOT NULL,
|
||||
`weight` DECIMAL(8,2) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_action_schedule` (`tpid`,`tag`,`actions_tag`)
|
||||
@@ -195,6 +204,7 @@ CREATE TABLE `tp_action_triggers` (
|
||||
`min_queued_items` int(11) NOT NULL,
|
||||
`actions_tag` varchar(64) NOT NULL,
|
||||
`weight` DECIMAL(8,2) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_trigger_definition` (`tpid`,`tag`,`balance_type`,`direction`,`threshold_type`,`threshold_value`,`destination_tag`,`actions_tag`)
|
||||
@@ -214,6 +224,7 @@ CREATE TABLE `tp_account_actions` (
|
||||
`direction` varchar(8) NOT NULL,
|
||||
`action_plan_tag` varchar(64),
|
||||
`action_triggers_tag` varchar(64),
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_tp_account` (`tpid`,`loadid`,`tenant`,`account`,`direction`)
|
||||
@@ -236,6 +247,7 @@ CREATE TABLE tp_lcr_rules (
|
||||
`suppliers` varchar(64) NOT NULL,
|
||||
`activation_time` varchar(24) NOT NULL,
|
||||
`weight` DECIMAL(8,2) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`)
|
||||
);
|
||||
@@ -266,6 +278,7 @@ CREATE TABLE tp_derived_chargers (
|
||||
`setup_time_field` varchar(24) NOT NULL,
|
||||
`answer_time_field` varchar(24) NOT NULL,
|
||||
`usage_field` varchar(24) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`)
|
||||
);
|
||||
@@ -300,6 +313,7 @@ CREATE TABLE tp_cdr_stats (
|
||||
`rated_subject` varchar(64) NOT NULL,
|
||||
`cost_interval` varchar(24) NOT NULL,
|
||||
`action_triggers` varchar(64) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`)
|
||||
);
|
||||
|
||||
@@ -21,6 +21,8 @@ CREATE TABLE cdrs_primary (
|
||||
setup_time TIMESTAMP NOT NULL,
|
||||
answer_time TIMESTAMP NOT NULL,
|
||||
usage NUMERIC(30,9) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
UNIQUE (cgrid)
|
||||
);
|
||||
|
||||
@@ -33,6 +35,8 @@ CREATE TABLE cdrs_extra (
|
||||
id SERIAL PRIMARY KEY,
|
||||
cgrid CHAR(40) NOT NULL,
|
||||
extra_fields text NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
UNIQUE (cgrid)
|
||||
);
|
||||
|
||||
@@ -56,6 +60,9 @@ CREATE TABLE cost_details (
|
||||
destination VARCHAR(128) NOT NULL,
|
||||
cost NUMERIC(20,4) NOT NULL,
|
||||
timespans text,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT NULL,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
UNIQUE (cgrid, runid)
|
||||
);
|
||||
|
||||
@@ -80,5 +87,8 @@ CREATE TABLE rated_cdrs (
|
||||
usage NUMERIC(30,9) NOT NULL,
|
||||
cost NUMERIC(20,4) DEFAULT NULL,
|
||||
extra_info text,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT NULL,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
UNIQUE (cgrid, runid)
|
||||
);
|
||||
@@ -11,6 +11,7 @@ CREATE TABLE tp_timings (
|
||||
month_days VARCHAR(255) NOT NULL,
|
||||
week_days VARCHAR(255) NOT NULL,
|
||||
time VARCHAR(16) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag)
|
||||
);
|
||||
|
||||
@@ -24,6 +25,7 @@ CREATE TABLE tp_destinations (
|
||||
tpid VARCHAR(64) NOT NULL,
|
||||
tag VARCHAR(64) NOT NULL,
|
||||
prefix VARCHAR(24) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, prefix)
|
||||
);
|
||||
|
||||
@@ -41,6 +43,7 @@ CREATE TABLE tp_rates (
|
||||
rate_unit VARCHAR(16) NOT NULL,
|
||||
rate_increment VARCHAR(16) NOT NULL,
|
||||
group_interval_start VARCHAR(16) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, group_interval_start)
|
||||
);
|
||||
|
||||
@@ -57,6 +60,7 @@ CREATE TABLE tp_destination_rates (
|
||||
rates_tag VARCHAR(64) NOT NULL,
|
||||
rounding_method VARCHAR(255) NOT NULL,
|
||||
rounding_decimals SMALLINT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag , destinations_tag)
|
||||
);
|
||||
|
||||
@@ -72,6 +76,7 @@ CREATE TABLE tp_rating_plans (
|
||||
destrates_tag VARCHAR(64) NOT NULL,
|
||||
timing_tag VARCHAR(64) NOT NULL,
|
||||
weight NUMERIC(8,2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, destrates_tag, timing_tag)
|
||||
);
|
||||
|
||||
@@ -91,6 +96,7 @@ CREATE TABLE tp_rating_profiles (
|
||||
activation_time VARCHAR(24) NOT NULL,
|
||||
rating_plan_tag VARCHAR(64) NOT NULL,
|
||||
fallback_subjects VARCHAR(64),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, loadid, tenant, category, direction, subject, activation_time)
|
||||
);
|
||||
|
||||
@@ -106,6 +112,7 @@ CREATE TABLE tp_shared_groups (
|
||||
account VARCHAR(24) NOT NULL,
|
||||
strategy VARCHAR(24) NOT NULL,
|
||||
rating_subject VARCHAR(24) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, account , strategy , rating_subject)
|
||||
);
|
||||
|
||||
@@ -130,6 +137,7 @@ CREATE TABLE tp_actions (
|
||||
balance_weight NUMERIC(8,2) NOT NULL,
|
||||
extra_parameters VARCHAR(256) NOT NULL,
|
||||
weight NUMERIC(8,2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, action, balance_type, direction, expiry_time, destination_tag, shared_group, balance_weight, weight)
|
||||
);
|
||||
|
||||
@@ -145,6 +153,7 @@ CREATE TABLE tp_action_plans (
|
||||
actions_tag VARCHAR(64) NOT NULL,
|
||||
timing_tag VARCHAR(64) NOT NULL,
|
||||
weight NUMERIC(8,2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, actions_tag)
|
||||
);
|
||||
|
||||
@@ -172,6 +181,7 @@ CREATE TABLE tp_action_triggers (
|
||||
min_queued_items INTEGER NOT NULL,
|
||||
actions_tag VARCHAR(64) NOT NULL,
|
||||
weight NUMERIC(8,2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, tag, balance_type, direction, threshold_type, threshold_value, destination_tag, actions_tag)
|
||||
);
|
||||
|
||||
@@ -189,6 +199,7 @@ CREATE TABLE tp_account_actions (
|
||||
direction VARCHAR(8) NOT NULL,
|
||||
action_plan_tag VARCHAR(64),
|
||||
action_triggers_tag VARCHAR(64),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (tpid, loadid, tenant, account, direction)
|
||||
);
|
||||
|
||||
@@ -208,7 +219,8 @@ CREATE TABLE tp_lcr_rules (
|
||||
strategy VARCHAR(16) NOT NULL,
|
||||
suppliers VARCHAR(64) NOT NULL,
|
||||
activation_time VARCHAR(24) NOT NULL,
|
||||
weight NUMERIC(8,2) NOT NULL
|
||||
weight NUMERIC(8,2) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
--
|
||||
@@ -236,7 +248,8 @@ CREATE TABLE tp_derived_chargers (
|
||||
destination_field VARCHAR(24) NOT NULL,
|
||||
setup_time_field VARCHAR(24) NOT NULL,
|
||||
answer_time_field VARCHAR(24) NOT NULL,
|
||||
usage_field VARCHAR(24) NOT NULL
|
||||
usage_field VARCHAR(24) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
@@ -268,5 +281,6 @@ CREATE TABLE tp_cdr_stats (
|
||||
rated_account VARCHAR(64) NOT NULL,
|
||||
rated_subject VARCHAR(64) NOT NULL,
|
||||
cost_interval VARCHAR(24) NOT NULL,
|
||||
action_triggers VARCHAR(64) NOT NULL
|
||||
action_triggers VARCHAR(64) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
@@ -38,13 +38,15 @@ type TpTiming struct {
|
||||
MonthDays string
|
||||
WeekDays string
|
||||
Time string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpDestination struct {
|
||||
Id int64
|
||||
Tpid string
|
||||
Tag string
|
||||
Prefix string
|
||||
Id int64
|
||||
Tpid string
|
||||
Tag string
|
||||
Prefix string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpRate struct {
|
||||
@@ -56,6 +58,7 @@ type TpRate struct {
|
||||
RateUnit string
|
||||
RateIncrement string
|
||||
GroupIntervalStart string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpDestinationRate struct {
|
||||
@@ -66,6 +69,7 @@ type TpDestinationRate struct {
|
||||
RatesTag string
|
||||
RoundingMethod string
|
||||
RoundingDecimals int
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpRatingPlan struct {
|
||||
@@ -75,6 +79,7 @@ type TpRatingPlan struct {
|
||||
DestratesTag string
|
||||
TimingTag string
|
||||
Weight float64
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpRatingProfile struct {
|
||||
@@ -88,6 +93,7 @@ type TpRatingProfile struct {
|
||||
ActivationTime string
|
||||
RatingPlanTag string
|
||||
FallbackSubjects string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (rpf *TpRatingProfile) SetRatingProfileId(id string) error {
|
||||
@@ -115,6 +121,7 @@ type TpLcrRules struct {
|
||||
Suppliers string
|
||||
ActivatinTime string
|
||||
Weight float64
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpAction struct {
|
||||
@@ -133,6 +140,7 @@ type TpAction struct {
|
||||
BalanceWeight float64
|
||||
ExtraParameters string
|
||||
Weight float64
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpActionPlan struct {
|
||||
@@ -142,6 +150,7 @@ type TpActionPlan struct {
|
||||
ActionsTag string
|
||||
TimingTag string
|
||||
Weight float64
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpActionTrigger struct {
|
||||
@@ -163,6 +172,7 @@ type TpActionTrigger struct {
|
||||
MinQueuedItems int
|
||||
ActionsTag string
|
||||
Weight float64
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpAccountAction struct {
|
||||
@@ -174,6 +184,7 @@ type TpAccountAction struct {
|
||||
Account string
|
||||
ActionPlanTag string
|
||||
ActionTriggersTag string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (aa *TpAccountAction) SetAccountActionId(id string) error {
|
||||
@@ -195,6 +206,7 @@ type TpSharedGroup struct {
|
||||
Account string
|
||||
Strategy string
|
||||
RatingSubject string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TpDerivedCharger struct {
|
||||
@@ -218,6 +230,7 @@ type TpDerivedCharger struct {
|
||||
SetupTimeField string
|
||||
AnswerTimeField string
|
||||
UsageField string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (tpdc *TpDerivedCharger) SetDerivedChargersId(id string) error {
|
||||
@@ -258,6 +271,7 @@ type TpCdrStat struct {
|
||||
RatedSubject string
|
||||
CostInterval string
|
||||
ActionTriggers string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type TblCdrsPrimary struct {
|
||||
@@ -277,6 +291,8 @@ type TblCdrsPrimary struct {
|
||||
SetupTime time.Time
|
||||
AnswerTime time.Time
|
||||
Usage float64
|
||||
CreatedAt time.Time
|
||||
DeletedAt time.Time
|
||||
}
|
||||
|
||||
func (t TblCdrsPrimary) TableName() string {
|
||||
@@ -287,6 +303,8 @@ type TblCdrsExtra struct {
|
||||
Id int64
|
||||
Cgrid string
|
||||
ExtraFields string
|
||||
CreatedAt time.Time
|
||||
DeletedAt time.Time
|
||||
}
|
||||
|
||||
func (t TblCdrsExtra) TableName() string {
|
||||
@@ -308,6 +326,9 @@ type TblCostDetail struct {
|
||||
Destination string
|
||||
Cost float64
|
||||
Timespans string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt time.Time
|
||||
}
|
||||
|
||||
type TblRatedCdr struct {
|
||||
@@ -327,4 +348,7 @@ type TblRatedCdr struct {
|
||||
Usage float64
|
||||
Cost float64
|
||||
ExtraInfo string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt time.Time
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (self *SQLStorage) GetTPIds() ([]string, error) {
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// ToDo: PSQL TEST
|
||||
// ToDo: TEST
|
||||
func (self *SQLStorage) GetTPTableIds(tpid, table string, distinct utils.TPDistinctIds, filters map[string]string, pagination *utils.Paginator) ([]string, error) {
|
||||
|
||||
qry := fmt.Sprintf("SELECT DISTINCT %s FROM %s where tpid='%s'", distinct, table, tpid)
|
||||
@@ -632,15 +632,11 @@ func (self *SQLStorage) SetTPAccountActions(tpid string, aas map[string]*utils.T
|
||||
}
|
||||
tx := self.db.Begin()
|
||||
for _, aa := range aas {
|
||||
// parse identifiers
|
||||
tx.Where("tpid = ?", tpid).
|
||||
Where("direction = ?", aa.Direction).
|
||||
Where("tenant = ?", aa.Tenant).
|
||||
Where("account = ?", aa.Account).
|
||||
Where("loadid = ?", aa.LoadId).
|
||||
Delete(TpAccountAction{})
|
||||
|
||||
tx.Save(TpAccountAction{
|
||||
if err := tx.Where(&TpAccountAction{Tpid: tpid, Loadid: aa.LoadId, Direction: aa.Direction, Tenant: aa.Tenant, Account: aa.Account}).Delete(TpAccountAction{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
saved := tx.Save(TpAccountAction{
|
||||
Tpid: aa.TPid,
|
||||
Loadid: aa.LoadId,
|
||||
Tenant: aa.Tenant,
|
||||
@@ -649,6 +645,10 @@ func (self *SQLStorage) SetTPAccountActions(tpid string, aas map[string]*utils.T
|
||||
ActionPlanTag: aa.ActionPlanId,
|
||||
ActionTriggersTag: aa.ActionTriggersId,
|
||||
})
|
||||
if saved.Error != nil {
|
||||
tx.Rollback()
|
||||
return saved.Error
|
||||
}
|
||||
}
|
||||
tx.Commit()
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user