mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Renaming tag->id and old id->tbid in mysql tables
This commit is contained in:
@@ -34,8 +34,8 @@ type AttrAcntAction struct {
|
||||
}
|
||||
|
||||
type AccountActionTiming struct {
|
||||
Id string // The id to reference this particular ActionTiming
|
||||
ActionPlanId string // The id of the ActionPlanId profile attached to the account
|
||||
Id string // The id to reference this particular ActionTiming
|
||||
ActionsId string // The id of actions which will be executed
|
||||
NextExecTime time.Time // Next execution time
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ func TestApierTPActions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierTPActionTimings(t *testing.T) {
|
||||
func TestApierTPActionPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ func (self *ApierV1) GetTPActionIds(attrs AttrGetTPActionIds, reply *[]string) e
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTIONS, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTIONS, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -73,7 +73,7 @@ func (self *ApierV1) GetTPActionPlanIds(attrs AttrGetTPActionPlanIds, reply *[]s
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_PLANS, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_PLANS, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -71,7 +71,7 @@ func (self *ApierV1) GetTPActionTriggerIds(attrs AttrGetTPActionTriggerIds, repl
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_TRIGGERS, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_TRIGGERS, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -68,7 +68,7 @@ func (self *ApierV1) GetTPDestinationRateIds(attrs AttrGetTPRateIds, reply *[]st
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATION_RATES, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATION_RATES, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -67,7 +67,7 @@ func (self *ApierV1) GetTPDestinationIds(attrs AttrGetTPDestinationIds, reply *[
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATIONS, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATIONS, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -68,7 +68,7 @@ func (self *ApierV1) GetTPRateIds(attrs AttrGetTPRateIds, reply *[]string) error
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATES, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATES, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -68,7 +68,7 @@ func (self *ApierV1) GetTPRatingPlanIds(attrs AttrGetTPRatingPlanIds, reply *[]s
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATING_PLANS, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATING_PLANS, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -70,7 +70,7 @@ func (self *ApierV1) GetTPTimingIds(attrs AttrGetTPTimingIds, reply *[]string) e
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_TIMINGS, "tag", nil); err != nil {
|
||||
if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_TIMINGS, "id", nil); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -26,23 +26,23 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["get_account"] = &CmdGetBalances{}
|
||||
commands["get_account"] = &CmdGetAccount{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdGetBalances struct {
|
||||
type CmdGetAccount struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrGetAccount
|
||||
rpcResult *engine.Account
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdGetBalances) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] get_balances <tenant> <account>")
|
||||
func (self *CmdGetAccount) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] get_account <tenant> <account>")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdGetBalances) defaults() error {
|
||||
func (self *CmdGetAccount) defaults() error {
|
||||
self.rpcMethod = "ApierV1.GetAccount"
|
||||
self.rpcParams = &apier.AttrGetAccount{BalanceType: engine.CREDIT}
|
||||
self.rpcParams.Direction = "*out"
|
||||
@@ -50,7 +50,7 @@ func (self *CmdGetBalances) defaults() error {
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdGetBalances) FromArgs(args []string) error {
|
||||
func (self *CmdGetAccount) FromArgs(args []string) error {
|
||||
if len(args) < 4 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
@@ -61,14 +61,14 @@ func (self *CmdGetBalances) FromArgs(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdGetBalances) RpcMethod() string {
|
||||
func (self *CmdGetAccount) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdGetBalances) RpcParams() interface{} {
|
||||
func (self *CmdGetAccount) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdGetBalances) RpcResult() interface{} {
|
||||
func (self *CmdGetAccount) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
DROP TABLE IF EXISTS cdrs_primary;
|
||||
|
||||
CREATE TABLE cdrs_primary (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
tbid int(11) NOT NULL AUTO_INCREMENT,
|
||||
cgrid char(40) NOT NULL,
|
||||
accid varchar(64) NOT NULL,
|
||||
cdrhost varchar(64) NOT NULL,
|
||||
@@ -15,16 +15,16 @@ CREATE TABLE cdrs_primary (
|
||||
destination varchar(128) NOT NULL,
|
||||
answer_time datetime NOT NULL,
|
||||
duration bigint NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
PRIMARY KEY (tbid),
|
||||
UNIQUE KEY cgrid (cgrid)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS cdrs_extra;
|
||||
|
||||
CREATE TABLE cdrs_extra (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
tbid int(11) NOT NULL AUTO_INCREMENT,
|
||||
cgrid char(40) NOT NULL,
|
||||
extra_fields text NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
PRIMARY KEY (tbid),
|
||||
UNIQUE KEY cgrid (cgrid)
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
DROP TABLE IF EXISTS `cost_details`;
|
||||
CREATE TABLE `cost_details` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`cgrid` char(40) NOT NULL,
|
||||
`accid` varchar(64) NOT NULL,
|
||||
`direction` varchar(8) NOT NULL,
|
||||
@@ -19,7 +19,7 @@ CREATE TABLE `cost_details` (
|
||||
`source` varchar(64) NOT NULL,
|
||||
`runid` varchar(64) NOT NULL,
|
||||
`cost_time` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
UNIQUE KEY `costid` (`cgrid`,`runid`)
|
||||
);
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
--
|
||||
DROP TABLE IF EXISTS `rated_cdrs`;
|
||||
CREATE TABLE `rated_cdrs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`cgrid` char(40) NOT NULL,
|
||||
`runid` varchar(64) NOT NULL,
|
||||
`subject` varchar(64) NOT NULL,
|
||||
`cost` DECIMAL(20,4) DEFAULT NULL,
|
||||
`mediation_time` datetime NOT NULL,
|
||||
`extra_info` text,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
UNIQUE KEY `costid` (`cgrid`,`runid`)
|
||||
);
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
--
|
||||
DROP TABLE IF EXISTS `tp_timings`;
|
||||
CREATE TABLE `tp_timings` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`years` varchar(255) NOT NULL,
|
||||
`months` varchar(255) NOT NULL,
|
||||
`month_days` varchar(255) NOT NULL,
|
||||
`week_days` varchar(255) NOT NULL,
|
||||
`time` varchar(16) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_tag` (`tpid`,`tag`),
|
||||
UNIQUE KEY `tpid_tmid` (`tpid`,`tag`)
|
||||
KEY `tpid_tmid` (`tpid`,`id`),
|
||||
UNIQUE KEY `tpid_id` (`tpid`,`id`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -23,14 +23,14 @@ CREATE TABLE `tp_timings` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_destinations`;
|
||||
CREATE TABLE `tp_destinations` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`prefix` varchar(24) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_tag` (`tpid`,`tag`),
|
||||
UNIQUE KEY `tpid_dest_prefix` (`tpid`,`tag`,`prefix`)
|
||||
KEY `tpid_dstid` (`tpid`,`id`),
|
||||
UNIQUE KEY `tpid_dest_prefix` (`tpid`,`id`,`prefix`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -39,9 +39,9 @@ CREATE TABLE `tp_destinations` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_rates`;
|
||||
CREATE TABLE `tp_rates` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`connect_fee` decimal(5,4) NOT NULL,
|
||||
`rate` DECIMAL(5,4) NOT NULL,
|
||||
`rate_unit` varchar(16) NOT NULL,
|
||||
@@ -49,10 +49,10 @@ CREATE TABLE `tp_rates` (
|
||||
`group_interval_start` varchar(16) NOT NULL,
|
||||
`rounding_method` varchar(255) NOT NULL,
|
||||
`rounding_decimals` tinyint(4) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_tprate` (`tpid`,`tag`,`group_interval_start`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
UNIQUE KEY `unique_tprate` (`tpid`,`id`,`group_interval_start`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_tag` (`tpid`,`tag`)
|
||||
KEY `tpid_rtid` (`tpid`,`id`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -61,15 +61,15 @@ CREATE TABLE `tp_rates` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_destination_rates`;
|
||||
CREATE TABLE `tp_destination_rates` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`destinations_tag` varchar(64) NOT NULL,
|
||||
`rates_tag` varchar(64) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
`id` varchar(64) NOT NULL,
|
||||
`destinations_id` varchar(64) NOT NULL,
|
||||
`rates_id` varchar(64) NOT NULL,
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_tag` (`tpid`,`tag`),
|
||||
UNIQUE KEY `tpid_tag_dst_rates` (`tpid`,`tag`,`destinations_tag`)
|
||||
KEY `tpid_drid` (`tpid`,`id`),
|
||||
UNIQUE KEY `tpid_drid_dstid` (`tpid`,`id`,`destinations_id`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -78,16 +78,16 @@ CREATE TABLE `tp_destination_rates` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_rating_plans`;
|
||||
CREATE TABLE `tp_rating_plans` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`destrates_tag` varchar(64) NOT NULL,
|
||||
`timing_tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`destrates_id` varchar(64) NOT NULL,
|
||||
`timing_id` varchar(64) NOT NULL,
|
||||
`weight` double(8,2) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
KEY `tpid_tag` (`tpid`,`tag`),
|
||||
UNIQUE KEY `tpid_tag_destrates_timings_weight` (`tpid`,`tag`,`destrates_tag`,`timing_tag`)
|
||||
KEY `tpid_rpl` (`tpid`,`id`),
|
||||
UNIQUE KEY `tpid_rplid_destrates_timings_weight` (`tpid`,`id`,`destrates_id`,`timing_id`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -96,7 +96,7 @@ CREATE TABLE `tp_rating_plans` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_rating_profiles`;
|
||||
CREATE TABLE `tp_rating_profiles` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`loadid` varchar(64) NOT NULL,
|
||||
`tenant` varchar(64) NOT NULL,
|
||||
@@ -104,11 +104,11 @@ CREATE TABLE `tp_rating_profiles` (
|
||||
`direction` varchar(8) NOT NULL,
|
||||
`subject` varchar(64) NOT NULL,
|
||||
`activation_time` varchar(24) NOT NULL,
|
||||
`rating_plan_tag` varchar(64) NOT NULL,
|
||||
`rating_plan_id` varchar(64) NOT NULL,
|
||||
`fallback_subjects` varchar(64),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid_tag` (`tpid`, `loadid`),
|
||||
UNIQUE KEY `tpid_tag_tenant_tor_dir_subj_atime` (`tpid`,`loadid`, `tenant`,`tor`,`direction`,`subject`,`activation_time`)
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid_loadid` (`tpid`, `loadid`),
|
||||
UNIQUE KEY `tpid_loadid_tenant_tor_dir_subj_atime` (`tpid`,`loadid`, `tenant`,`tor`,`direction`,`subject`,`activation_time`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -117,15 +117,15 @@ CREATE TABLE `tp_rating_profiles` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_shared_groups`;
|
||||
CREATE TABLE `tp_shared_groups` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`account` varchar(24) NOT NULL,
|
||||
`strategy` varchar(24) NOT NULL,
|
||||
`rate_subject` varchar(24) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
`rating_subject` varchar(24) NOT NULL,
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_shared_group` (`tpid`,`tag`,`account`,`strategy`,`rate_subject`)
|
||||
UNIQUE KEY `unique_shared_group` (`tpid`,`id`,`account`,`strategy`,`rating_subject`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -134,23 +134,23 @@ CREATE TABLE `tp_shared_groups` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_actions`;
|
||||
CREATE TABLE `tp_actions` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`action` varchar(24) NOT NULL,
|
||||
`balance_type` varchar(24) NOT NULL,
|
||||
`direction` varchar(8) NOT NULL,
|
||||
`units` double(20,4) NOT NULL,
|
||||
`expiry_time` varchar(24) NOT NULL,
|
||||
`destination_tag` varchar(64) NOT NULL,
|
||||
`destination_id` varchar(64) NOT NULL,
|
||||
`rating_subject` varchar(64) NOT NULL,
|
||||
`shared_group` varchar(64) NOT NULL,
|
||||
`balance_weight` double(8,2) NOT NULL,
|
||||
`extra_parameters` varchar(256) NOT NULL,
|
||||
`weight` double(8,2) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_action` (`tpid`,`tag`,`action`,`balance_type`,`direction`,`expiry_time`,`destination_tag`,`shared_group`,`balance_weight`,`weight`)
|
||||
UNIQUE KEY `unique_action` (`tpid`,`id`,`action`,`balance_type`,`direction`,`expiry_time`,`destination_id`,`shared_group`,`balance_weight`,`weight`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -159,15 +159,15 @@ CREATE TABLE `tp_actions` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_action_plans`;
|
||||
CREATE TABLE `tp_action_plans` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`actions_tag` varchar(64) NOT NULL,
|
||||
`timing_tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`actions_id` varchar(64) NOT NULL,
|
||||
`timing_id` varchar(64) NOT NULL,
|
||||
`weight` double(8,2) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_action_schedule` (`tpid`,`tag`,`actions_tag`)
|
||||
UNIQUE KEY `unique_action_schedule` (`tpid`,`id`,`actions_id`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -176,19 +176,19 @@ CREATE TABLE `tp_action_plans` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_action_triggers`;
|
||||
CREATE TABLE `tp_action_triggers` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`balance_type` varchar(24) NOT NULL,
|
||||
`direction` varchar(8) NOT NULL,
|
||||
`threshold_type` char(12) NOT NULL,
|
||||
`threshold_value` double(20,4) NOT NULL,
|
||||
`destination_tag` varchar(64) NOT NULL,
|
||||
`actions_tag` varchar(64) NOT NULL,
|
||||
`destination_id` varchar(64) NOT NULL,
|
||||
`actions_id` varchar(64) NOT NULL,
|
||||
`weight` double(8,2) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_trigger_definition` (`tpid`,`tag`,`balance_type`,`direction`,`threshold_type`,`threshold_value`,`destination_tag`,`actions_tag`)
|
||||
UNIQUE KEY `unique_trigger_definition` (`tpid`,`id`,`balance_type`,`direction`,`threshold_type`,`threshold_value`,`destination_id`,`actions_id`)
|
||||
);
|
||||
|
||||
--
|
||||
@@ -197,15 +197,15 @@ CREATE TABLE `tp_action_triggers` (
|
||||
|
||||
DROP TABLE IF EXISTS `tp_account_actions`;
|
||||
CREATE TABLE `tp_account_actions` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tbid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`loadid` varchar(64) NOT NULL,
|
||||
`tenant` varchar(64) NOT NULL,
|
||||
`account` varchar(64) NOT NULL,
|
||||
`direction` varchar(8) NOT NULL,
|
||||
`action_timings_tag` varchar(64),
|
||||
`action_triggers_tag` varchar(64),
|
||||
PRIMARY KEY (`id`),
|
||||
`action_plan_id` varchar(64),
|
||||
`action_triggers_id` varchar(64),
|
||||
PRIMARY KEY (`tbid`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_tp_account` (`tpid`,`loadid`,`tenant`,`account`,`direction`)
|
||||
);
|
||||
|
||||
@@ -116,7 +116,7 @@ func (self *SQLStorage) GetTPTableIds(tpid, table, distinct string, filters map[
|
||||
}
|
||||
|
||||
func (self *SQLStorage) SetTPTiming(tpid string, tm *utils.TPTiming) error {
|
||||
if _, err := self.Db.Exec(fmt.Sprintf("INSERT INTO %s (tpid, tag, years, months, month_days, week_days, time) VALUES('%s','%s','%s','%s','%s','%s','%s') ON DUPLICATE KEY UPDATE years=values(years), months=values(months), month_days=values(month_days), week_days=values(week_days), time=values(time)",
|
||||
if _, err := self.Db.Exec(fmt.Sprintf("INSERT INTO %s (tpid, id, years, months, month_days, week_days, time) VALUES('%s','%s','%s','%s','%s','%s','%s') ON DUPLICATE KEY UPDATE years=values(years), months=values(months), month_days=values(month_days), week_days=values(week_days), time=values(time)",
|
||||
utils.TBL_TP_TIMINGS, tpid, tm.Id, tm.Years.Serialize(";"), tm.Months.Serialize(";"), tm.MonthDays.Serialize(";"),
|
||||
tm.WeekDays.Serialize(";"), tm.StartTime)); err != nil {
|
||||
return err
|
||||
@@ -125,7 +125,7 @@ func (self *SQLStorage) SetTPTiming(tpid string, tm *utils.TPTiming) error {
|
||||
}
|
||||
|
||||
func (self *SQLStorage) RemTPData(table, tpid string, args ...string) error {
|
||||
q := fmt.Sprintf("DELETE FROM %s WHERE tpid='%s' AND tag='%s'", table, tpid, args[0])
|
||||
q := fmt.Sprintf("DELETE FROM %s WHERE tpid='%s' AND id='%s'", table, tpid, args[0])
|
||||
switch table {
|
||||
case utils.TBL_TP_RATE_PROFILES:
|
||||
q = fmt.Sprintf("DELETE FROM %s WHERE tpid='%s' AND loadid='%s' AND tenant='%s' AND tor='%s' AND direction='%s' AND subject='%s'",
|
||||
@@ -142,7 +142,7 @@ func (self *SQLStorage) RemTPData(table, tpid string, args ...string) error {
|
||||
|
||||
// Extracts destinations from StorDB on specific tariffplan id
|
||||
func (self *SQLStorage) GetTPDestination(tpid, destTag string) (*Destination, error) {
|
||||
rows, err := self.Db.Query(fmt.Sprintf("SELECT prefix FROM %s WHERE tpid='%s' AND tag='%s'", utils.TBL_TP_DESTINATIONS, tpid, destTag))
|
||||
rows, err := self.Db.Query(fmt.Sprintf("SELECT prefix FROM %s WHERE tpid='%s' AND id='%s'", utils.TBL_TP_DESTINATIONS, tpid, destTag))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func (self *SQLStorage) SetTPDestination(tpid string, dest *Destination) error {
|
||||
return nil
|
||||
}
|
||||
var buffer bytes.Buffer // Use bytes buffer istead of string concatenation since that becomes quite heavy on large prefixes
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, tag, prefix) VALUES ", utils.TBL_TP_DESTINATIONS))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, id, prefix) VALUES ", utils.TBL_TP_DESTINATIONS))
|
||||
for idx, prefix := range dest.Prefixes {
|
||||
if idx != 0 {
|
||||
buffer.WriteRune(',')
|
||||
@@ -189,7 +189,7 @@ func (self *SQLStorage) SetTPRates(tpid string, rts map[string][]*utils.RateSlot
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, tag, connect_fee, rate, rate_unit, rate_increment, group_interval_start, rounding_method, rounding_decimals) VALUES ",
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, id, connect_fee, rate, rate_unit, rate_increment, group_interval_start, rounding_method, rounding_decimals) VALUES ",
|
||||
utils.TBL_TP_RATES))
|
||||
i := 0
|
||||
for rtId, rtRows := range rts {
|
||||
@@ -215,7 +215,7 @@ func (self *SQLStorage) SetTPDestinationRates(tpid string, drs map[string][]*uti
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,tag,destinations_tag,rates_tag) VALUES ", utils.TBL_TP_DESTINATION_RATES))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,id,destinations_id,rates_id) VALUES ", utils.TBL_TP_DESTINATION_RATES))
|
||||
i := 0
|
||||
for drId, drRows := range drs {
|
||||
for _, dr := range drRows {
|
||||
@@ -226,7 +226,7 @@ func (self *SQLStorage) SetTPDestinationRates(tpid string, drs map[string][]*uti
|
||||
i++
|
||||
}
|
||||
}
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE destinations_tag=values(destinations_tag),rates_tag=values(rates_tag)")
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE destinations_id=values(destinations_id),rates_id=values(rates_id)")
|
||||
if _, err := self.Db.Exec(buffer.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func (self *SQLStorage) SetTPRatingPlans(tpid string, drts map[string][]*utils.T
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, tag, destrates_tag, timing_tag, weight) VALUES ", utils.TBL_TP_RATING_PLANS))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, id, destrates_id, timing_id, weight) VALUES ", utils.TBL_TP_RATING_PLANS))
|
||||
i := 0
|
||||
for drtId, drtRows := range drts {
|
||||
for _, drt := range drtRows {
|
||||
@@ -261,7 +261,7 @@ func (self *SQLStorage) SetTPRatingProfiles(tpid string, rps map[string]*utils.T
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,loadid,tenant,tor,direction,subject,activation_time,rating_plan_tag,fallback_subjects) VALUES ",
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,loadid,tenant,tor,direction,subject,activation_time,rating_plan_id,fallback_subjects) VALUES ",
|
||||
utils.TBL_TP_RATE_PROFILES))
|
||||
i := 0
|
||||
for _, rp := range rps {
|
||||
@@ -286,7 +286,7 @@ func (self *SQLStorage) SetTPSharedGroups(tpid string, sgs map[string]*SharedGro
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,tag,account,strategy,rate_subject) VALUES ", utils.TBL_TP_SHARED_GROUPS))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,id,account,strategy,rate_subject) VALUES ", utils.TBL_TP_SHARED_GROUPS))
|
||||
i := 0
|
||||
for sgId, sg := range sgs {
|
||||
for account, params := range sg.AccountParameters {
|
||||
@@ -310,7 +310,7 @@ func (self *SQLStorage) SetTPActions(tpid string, acts map[string][]*utils.TPAct
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,tag,action,balance_type,direction,units,expiry_time,destination_tag,rating_subject,shared_group,balance_weight,extra_parameters,weight) VALUES ", utils.TBL_TP_ACTIONS))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,id,action,balance_type,direction,units,expiry_time,destination_id,rating_subject,shared_group,balance_weight,extra_parameters,weight) VALUES ", utils.TBL_TP_ACTIONS))
|
||||
i := 0
|
||||
for actId, actRows := range acts {
|
||||
for _, act := range actRows {
|
||||
@@ -323,7 +323,7 @@ func (self *SQLStorage) SetTPActions(tpid string, acts map[string][]*utils.TPAct
|
||||
i++
|
||||
}
|
||||
}
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE action=values(action),balance_type=values(balance_type),direction=values(direction),units=values(units),expiry_time=values(expiry_time),destination_tag=values(destination_tag),rating_subject=values(rating_subject),shared_group=values(shared_group),balance_weight=values(balance_weight),extra_parameters=values(extra_parameters),weight=values(weight)")
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE action=values(action),balance_type=values(balance_type),direction=values(direction),units=values(units),expiry_time=values(expiry_time),destination_id=values(destination_id),rating_subject=values(rating_subject),shared_group=values(shared_group),balance_weight=values(balance_weight),extra_parameters=values(extra_parameters),weight=values(weight)")
|
||||
if _, err := self.Db.Exec(buffer.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -331,7 +331,7 @@ func (self *SQLStorage) SetTPActions(tpid string, acts map[string][]*utils.TPAct
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTPActions(tpid, actsId string) (*utils.TPActions, error) {
|
||||
rows, err := self.Db.Query(fmt.Sprintf("SELECT action,balance_type,direction,units,expiry_time,destination_tag,rating_subject,shared_group,balance_weight,extra_parameters,weight FROM %s WHERE tpid='%s' AND tag='%s'", utils.TBL_TP_ACTIONS, tpid, actsId))
|
||||
rows, err := self.Db.Query(fmt.Sprintf("SELECT action,balance_type,direction,units,expiry_time,destination_id,rating_subject,shared_group,balance_weight,extra_parameters,weight FROM %s WHERE tpid='%s' AND id='%s'", utils.TBL_TP_ACTIONS, tpid, actsId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -370,7 +370,7 @@ func (self *SQLStorage) SetTPActionTimings(tpid string, ats map[string][]*utils.
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,tag,actions_tag,timing_tag,weight) VALUES ", utils.TBL_TP_ACTION_PLANS))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,id,actions_id,timing_id,weight) VALUES ", utils.TBL_TP_ACTION_PLANS))
|
||||
i := 0
|
||||
for atId, atRows := range ats {
|
||||
for _, at := range atRows {
|
||||
@@ -381,7 +381,7 @@ func (self *SQLStorage) SetTPActionTimings(tpid string, ats map[string][]*utils.
|
||||
i++
|
||||
}
|
||||
}
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE timing_tag=values(timing_tag),weight=values(weight)")
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE timing_id=values(timing_id),weight=values(weight)")
|
||||
if _, err := self.Db.Exec(buffer.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -390,9 +390,9 @@ func (self *SQLStorage) SetTPActionTimings(tpid string, ats map[string][]*utils.
|
||||
|
||||
func (self *SQLStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTiming, error) {
|
||||
ats := make(map[string][]*utils.TPActionTiming)
|
||||
q := fmt.Sprintf("SELECT tag,actions_tag,timing_tag,weight FROM %s WHERE tpid='%s'", utils.TBL_TP_ACTION_PLANS, tpid)
|
||||
q := fmt.Sprintf("SELECT id,actions_id,timing_id,weight FROM %s WHERE tpid='%s'", utils.TBL_TP_ACTION_PLANS, tpid)
|
||||
if atId != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", atId)
|
||||
q += fmt.Sprintf(" AND id='%s'", atId)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -417,7 +417,7 @@ func (self *SQLStorage) SetTPActionTriggers(tpid string, ats map[string][]*utils
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,tag,balance_type,direction,threshold_type,threshold_value,destination_tag,actions_tag,weight) VALUES ",
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid,id,balance_type,direction,threshold_type,threshold_value,destination_id,actions_id,weight) VALUES ",
|
||||
utils.TBL_TP_ACTION_TRIGGERS))
|
||||
i := 0
|
||||
for atId, atRows := range ats {
|
||||
@@ -444,7 +444,7 @@ func (self *SQLStorage) SetTPAccountActions(tpid string, aa map[string]*utils.TP
|
||||
return nil //Nothing to set
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, loadid, tenant, account, direction, action_timings_tag, action_triggers_tag) VALUES ", utils.TBL_TP_ACCOUNT_ACTIONS))
|
||||
buffer.WriteString(fmt.Sprintf("INSERT INTO %s (tpid, loadid, tenant, account, direction, action_plan_id, action_triggers_id) VALUES ", utils.TBL_TP_ACCOUNT_ACTIONS))
|
||||
i := 0
|
||||
for _, aActs := range aa {
|
||||
if i != 0 { //Consecutive values after the first will be prefixed with "," as separator
|
||||
@@ -454,7 +454,7 @@ func (self *SQLStorage) SetTPAccountActions(tpid string, aa map[string]*utils.TP
|
||||
tpid, aActs.LoadId, aActs.Tenant, aActs.Account, aActs.Direction, aActs.ActionPlanId, aActs.ActionTriggersId))
|
||||
i++
|
||||
}
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE action_timings_tag=values(action_timings_tag), action_triggers_tag=values(action_triggers_tag)")
|
||||
buffer.WriteString(" ON DUPLICATE KEY UPDATE action_plan_id=values(action_plan_id), action_triggers_id=values(action_triggers_id)")
|
||||
if _, err := self.Db.Exec(buffer.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -660,8 +660,8 @@ func (self *SQLStorage) RemStoredCdrs(cgrIds []string) error {
|
||||
func (self *SQLStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error) {
|
||||
var dests []*Destination
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid='%s'", utils.TBL_TP_DESTINATIONS, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
if len(tag) != 0 {
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -692,9 +692,9 @@ func (self *SQLStorage) GetTpDestinations(tpid, tag string) ([]*Destination, err
|
||||
|
||||
func (self *SQLStorage) GetTpRates(tpid, tag string) (map[string]*utils.TPRate, error) {
|
||||
rts := make(map[string]*utils.TPRate)
|
||||
q := fmt.Sprintf("SELECT tag, connect_fee, rate, rate_unit, rate_increment, group_interval_start, rounding_method, rounding_decimals FROM %s WHERE tpid='%s' ", utils.TBL_TP_RATES, tpid)
|
||||
q := fmt.Sprintf("SELECT id, connect_fee, rate, rate_unit, rate_increment, group_interval_start, rounding_method, rounding_decimals FROM %s WHERE tpid='%s' ", utils.TBL_TP_RATES, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -738,7 +738,7 @@ func (self *SQLStorage) GetTpDestinationRates(tpid, tag string) (map[string]*uti
|
||||
rts := make(map[string]*utils.TPDestinationRate)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid='%s'", utils.TBL_TP_DESTINATION_RATES, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -777,7 +777,7 @@ func (self *SQLStorage) GetTpTimings(tpid, tag string) (map[string]*utils.TPTimi
|
||||
tms := make(map[string]*utils.TPTiming)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid='%s'", utils.TBL_TP_TIMINGS, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -799,7 +799,7 @@ func (self *SQLStorage) GetTpRatingPlans(tpid, tag string) (map[string][]*utils.
|
||||
rpbns := make(map[string][]*utils.TPRatingPlanBinding)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid='%s'", utils.TBL_TP_RATING_PLANS, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -828,7 +828,7 @@ func (self *SQLStorage) GetTpRatingPlans(tpid, tag string) (map[string][]*utils.
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTpRatingProfiles(qryRpf *utils.TPRatingProfile) (map[string]*utils.TPRatingProfile, error) {
|
||||
q := fmt.Sprintf("SELECT loadid,tenant,tor,direction,subject,activation_time,rating_plan_tag,fallback_subjects FROM %s WHERE tpid='%s'",
|
||||
q := fmt.Sprintf("SELECT loadid,tenant,tor,direction,subject,activation_time,rating_plan_id,fallback_subjects FROM %s WHERE tpid='%s'",
|
||||
utils.TBL_TP_RATE_PROFILES, qryRpf.TPid)
|
||||
if len(qryRpf.LoadId) != 0 {
|
||||
q += fmt.Sprintf(" AND loadid='%s'", qryRpf.LoadId)
|
||||
@@ -873,7 +873,7 @@ func (self *SQLStorage) GetTpSharedGroups(tpid, tag string) (map[string]*SharedG
|
||||
sgs := make(map[string]*SharedGroup)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid='%s'", utils.TBL_TP_SHARED_GROUPS, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -914,7 +914,7 @@ func (self *SQLStorage) GetTpActions(tpid, tag string) (map[string][]*utils.TPAc
|
||||
as := make(map[string][]*utils.TPAction)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid='%s'", utils.TBL_TP_ACTIONS, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -948,10 +948,10 @@ func (self *SQLStorage) GetTpActions(tpid, tag string) (map[string][]*utils.TPAc
|
||||
|
||||
func (self *SQLStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*utils.TPActionTrigger, error) {
|
||||
ats := make(map[string][]*utils.TPActionTrigger)
|
||||
q := fmt.Sprintf("SELECT tpid,tag,balance_type,direction,threshold_type,threshold_value,destination_tag,actions_tag,weight FROM %s WHERE tpid='%s'",
|
||||
q := fmt.Sprintf("SELECT tpid,id,balance_type,direction,threshold_type,threshold_value,destination_id,actions_id,weight FROM %s WHERE tpid='%s'",
|
||||
utils.TBL_TP_ACTION_TRIGGERS, tpid)
|
||||
if tag != "" {
|
||||
q += fmt.Sprintf(" AND tag='%s'", tag)
|
||||
q += fmt.Sprintf(" AND id='%s'", tag)
|
||||
}
|
||||
rows, err := self.Db.Query(q)
|
||||
if err != nil {
|
||||
@@ -980,7 +980,7 @@ func (self *SQLStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*uti
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTpAccountActions(aaFltr *utils.TPAccountActions) (map[string]*utils.TPAccountActions, error) {
|
||||
q := fmt.Sprintf("SELECT loadid, tenant, account, direction, action_timings_tag, action_triggers_tag FROM %s WHERE tpid='%s'", utils.TBL_TP_ACCOUNT_ACTIONS, aaFltr.TPid)
|
||||
q := fmt.Sprintf("SELECT loadid, tenant, account, direction, action_plan_id, action_triggers_id FROM %s WHERE tpid='%s'", utils.TBL_TP_ACCOUNT_ACTIONS, aaFltr.TPid)
|
||||
if len(aaFltr.LoadId) != 0 {
|
||||
q += fmt.Sprintf(" AND loadid='%s'", aaFltr.LoadId)
|
||||
}
|
||||
@@ -1000,8 +1000,8 @@ func (self *SQLStorage) GetTpAccountActions(aaFltr *utils.TPAccountActions) (map
|
||||
defer rows.Close()
|
||||
aa := make(map[string]*utils.TPAccountActions)
|
||||
for rows.Next() {
|
||||
var aaLoadId, tenant, account, direction, action_timings_tag, action_triggers_tag string
|
||||
if err := rows.Scan(&aaLoadId, &tenant, &account, &direction, &action_timings_tag, &action_triggers_tag); err != nil {
|
||||
var aaLoadId, tenant, account, direction, action_plan_tag, action_triggers_tag string
|
||||
if err := rows.Scan(&aaLoadId, &tenant, &account, &direction, &action_plan_tag, &action_triggers_tag); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
aacts := &utils.TPAccountActions{
|
||||
@@ -1010,7 +1010,7 @@ func (self *SQLStorage) GetTpAccountActions(aaFltr *utils.TPAccountActions) (map
|
||||
Tenant: tenant,
|
||||
Account: account,
|
||||
Direction: direction,
|
||||
ActionPlanId: action_timings_tag,
|
||||
ActionPlanId: action_plan_tag,
|
||||
ActionTriggersId: action_triggers_tag,
|
||||
}
|
||||
aa[aacts.KeyId()] = aacts
|
||||
|
||||
Reference in New Issue
Block a user