diff --git a/apier/v2/tp.go b/apier/v2/tp.go index 2053fc17e..2513f87f0 100644 --- a/apier/v2/tp.go +++ b/apier/v2/tp.go @@ -42,7 +42,7 @@ func (self *ApierV2) RemTP(attrs AttrRemTp, reply *string) error { } func (self *ApierV2) ExportTPToFolder(attrs utils.AttrDirExportTP, exported *utils.ExportedTPStats) error { - if len(*attrs.TPid) == 0 { + if attrs.TPid == nil || *attrs.TPid == "" { return utils.NewErrMandatoryIeMissing("TPid") } dir := self.Config.TpExportPath @@ -75,7 +75,7 @@ func (self *ApierV2) ExportTPToFolder(attrs utils.AttrDirExportTP, exported *uti } func (self *ApierV2) ExportTPToZipString(attrs utils.AttrDirExportTP, reply *string) error { - if len(*attrs.TPid) == 0 { + if attrs.TPid == nil || *attrs.TPid == "" { return utils.NewErrMandatoryIeMissing("TPid") } dir := "" diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql index 3e2fe6fa3..8bd959e31 100644 --- a/data/storage/mysql/create_tariffplan_tables.sql +++ b/data/storage/mysql/create_tariffplan_tables.sql @@ -399,8 +399,8 @@ DROP TABLE IF EXISTS tp_resources; CREATE TABLE tp_resources ( `pk` int(11) NOT NULL AUTO_INCREMENT, `tpid` varchar(64) NOT NULL, - `id` varchar(64) NOT NULL, `tenant` varchar(64) NOT NULL, + `id` varchar(64) NOT NULL, `filter_type` varchar(16) NOT NULL, `filter_field_name` varchar(64) NOT NULL, `filter_field_values` varchar(256) NOT NULL, @@ -415,7 +415,7 @@ CREATE TABLE tp_resources ( `created_at` TIMESTAMP, PRIMARY KEY (`pk`), KEY `tpid` (`tpid`), - UNIQUE KEY `unique_tp_resource` (`tpid`, `id`, `filter_type`, `filter_field_name`) + UNIQUE KEY `unique_tp_resource` (`tpid`,`tenant`, `id`, `filter_type`, `filter_field_name`) ); -- @@ -424,9 +424,9 @@ CREATE TABLE tp_resources ( DROP TABLE IF EXISTS tp_stats; CREATE TABLE tp_stats ( - `tenant` varchar(64) NOT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `tpid` varchar(64) NOT NULL, + `tenant` varchar(64) NOT NULL, `tag` varchar(64) NOT NULL, `filter_type` varchar(16) NOT NULL, `filter_field_name` varchar(64) NOT NULL, @@ -442,7 +442,7 @@ CREATE TABLE tp_stats ( `created_at` TIMESTAMP, PRIMARY KEY (`id`), KEY `tpid` (`tpid`), - UNIQUE KEY `unique_tp_stats` (`tpid`, `tag`, `filter_type`, `filter_field_name`) + UNIQUE KEY `unique_tp_stats` (`tpid`, `tenant`, `tag`, `filter_type`, `filter_field_name`) ); -- diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql index d065f2ca9..c2e9ef515 100644 --- a/data/storage/postgres/create_tariffplan_tables.sql +++ b/data/storage/postgres/create_tariffplan_tables.sql @@ -395,8 +395,8 @@ DROP TABLE IF EXISTS tp_resources; CREATE TABLE tp_resources ( "pk" SERIAL PRIMARY KEY, "tpid" varchar(64) NOT NULL, - "id" varchar(64) NOT NULL, "tenant"varchar(64) NOT NULL, + "id" varchar(64) NOT NULL, "filter_type" varchar(16) NOT NULL, "filter_field_name" varchar(64) NOT NULL, "filter_field_values" varchar(256) NOT NULL, @@ -411,7 +411,7 @@ CREATE TABLE tp_resources ( "created_at" TIMESTAMP WITH TIME ZONE ); CREATE INDEX tp_resources_idx ON tp_resources (tpid); -CREATE INDEX tp_resources_unique ON tp_resources ("tpid", "id", "filter_type", "filter_field_name"); +CREATE INDEX tp_resources_unique ON tp_resources ("tpid", "tenant", "id", "filter_type", "filter_field_name"); -- @@ -420,9 +420,9 @@ CREATE INDEX tp_resources_unique ON tp_resources ("tpid", "id", "filter_type", DROP TABLE IF EXISTS tp_stats; CREATE TABLE tp_stats ( - "tenant"varchar(64) NOT NULL, "id" SERIAL PRIMARY KEY, "tpid" varchar(64) NOT NULL, + "tenant"varchar(64) NOT NULL, "tag" varchar(64) NOT NULL, "filter_type" varchar(16) NOT NULL, "filter_field_name" varchar(64) NOT NULL, @@ -438,7 +438,7 @@ CREATE TABLE tp_stats ( "created_at" TIMESTAMP WITH TIME ZONE ); CREATE INDEX tp_stats_idx ON tp_stats (tpid); -CREATE INDEX tp_stats_unique ON tp_stats ("tpid", "tag", "filter_type", "filter_field_name"); +CREATE INDEX tp_stats_unique ON tp_stats ("tpid","tenant", "tag", "filter_type", "filter_field_name"); -- -- Table structure for table `tp_threshold_cfgs`