mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 17:18:44 +05:00
Add a new fild in models TPResource ID and replace primary key with PK and set tenant after ID
This commit is contained in:
@@ -565,7 +565,7 @@ func (self *SQLStorage) SetTPResources(rls []*utils.TPResource) error {
|
||||
tx := self.db.Begin()
|
||||
for _, rl := range rls {
|
||||
// Remove previous
|
||||
if err := tx.Where(&TpResource{Tpid: rl.TPid, Tag: rl.ID}).Delete(TpResource{}).Error; err != nil {
|
||||
if err := tx.Where(&TpResource{Tpid: rl.TPid, ID: rl.ID}).Delete(TpResource{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
@@ -1542,7 +1542,7 @@ func (self *SQLStorage) GetTPResources(tpid, id string) ([]*utils.TPResource, er
|
||||
var rls TpResources
|
||||
q := self.db.Where("tpid = ?", tpid)
|
||||
if len(id) != 0 {
|
||||
q = q.Where("tag = ?", id)
|
||||
q = q.Where("id = ?", id)
|
||||
}
|
||||
if err := q.Find(&rls).Error; err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user