From 01ada44d960490839cee674d2f048da048fa1009 Mon Sep 17 00:00:00 2001 From: Oluwatobi Bamidele Date: Sun, 1 Dec 2024 22:41:09 +0100 Subject: [PATCH] fix: create uuid before creating a ticket --- db/structs.go | 2 +- db/tickets.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/db/structs.go b/db/structs.go index 075cd5210..3df472a2b 100644 --- a/db/structs.go +++ b/db/structs.go @@ -958,7 +958,7 @@ const ( ) type Tickets struct { - UUID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` + UUID uuid.UUID `gorm:"primaryKey;type:uuid"` FeatureUUID string `gorm:"type:uuid;index:composite_index" json:"feature_uuid"` Features WorkspaceFeatures `gorm:"foreignKey:FeatureUUID;references:Uuid"` PhaseUUID string `gorm:"type:uuid;index:phase_index" json:"phase_uuid"` diff --git a/db/tickets.go b/db/tickets.go index f826dc511..f0cbfaca3 100644 --- a/db/tickets.go +++ b/db/tickets.go @@ -32,6 +32,8 @@ func (db database) CreateOrEditTicket(ticket *Tickets) (Tickets, error) { ticket.Status = DraftTicket } + ticket.UUID = uuid.New() + if err := db.db.Create(&ticket).Error; err != nil { return Tickets{}, fmt.Errorf("failed to create ticket: %w", err) }