Skip to content

Commit

Permalink
Update event on conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
DearRude committed Apr 29, 2024
1 parent a5767a3 commit 4472192
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions handlers/handle_commands.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package handlers

import (
"gorm.io/gorm"
"strconv"
"strings"

"github.com/DearRude/siahe/database"
in "github.com/DearRude/siahe/internals"

"gorm.io/gorm"
"gorm.io/gorm/clause"
)

func handleCommands(u in.UpdateMessage) error {
Expand Down Expand Up @@ -533,7 +535,10 @@ func addEventCommand(u in.UpdateMessage) error {
IsActive: true, // An event is a active by default
}

res := db.Create(&event)
res := db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "name"}},
DoUpdates: clause.AssignmentColumns([]string{"description", "is_paid", "max_ticket_batch", "place_id"}),
}).Create(&event)
if err := res.Error; err != nil {
if err := reactToMessage(u, "👎"); err != nil {
return err
Expand Down

0 comments on commit 4472192

Please sign in to comment.