Skip to content

Commit

Permalink
Merge pull request #2018 from stakwork/fix/ticket-uuid
Browse files Browse the repository at this point in the history
fix: create uuid before creating a ticket
  • Loading branch information
tobi-bams authored Dec 1, 2024
2 parents a7233aa + 01ada44 commit de42211
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 2 additions & 0 deletions db/tickets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit de42211

Please sign in to comment.