diff --git a/repository/repository.go b/repository/repository.go index 1a97306..e8e6e0c 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -249,7 +249,18 @@ func CreateSubscription(user entity.User, sites []string, subscriptionScheduleID tx.Where(entity.Subscription{ UserID: user.ID, - }).Assign(values).FirstOrCreate(&subscription).Association("Sites").Append(foundSites) + }).Find(&subscription) + + tx.Model(&subscription). + Association("Sites"). + Clear() + + tx.Where(entity.Subscription{ + UserID: user.ID, + }).Assign(values). + FirstOrCreate(&subscription). + Association("Sites"). + Append(foundSites) return nil }) return subscription