Skip to content

Commit

Permalink
feat(token): add token model
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu <[email protected]>
  • Loading branch information
mathieu-brl committed Dec 5, 2024
1 parent ec1ce93 commit 8f063b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/internal/models/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ type Service struct {
gorm.Model
Label string `json:"label"`
Events []Event `gorm:"constraint:OnDelete:CASCADE;" json:"events"`
Tokens []Token `gorm:"constraint:OnDelete:CASCADE;" json:"tokens"`
}
10 changes: 10 additions & 0 deletions server/internal/models/token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package models

import "gorm.io/gorm"

type Token struct {
gorm.Model
Value string
ServiceID uint
UserID uint
}
1 change: 1 addition & 0 deletions server/internal/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ type User struct {
Salt string `gorm:"not null" json:"salt"`
Token string `gorm:"not null" json:"token"`
Workflows []Workflow `gorm:"constraint:OnDelete:CASCADE;"`
Tokens []Token `gorm:"constraint:OnDelete:CASCADE;"`
}
1 change: 1 addition & 0 deletions server/internal/pkg/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func migrateDB() error {
&models.Event{},
&models.Parameters{},
&models.Service{},
&models.Token{},
)
if err != nil {
log.Fatalf("Failed to migrate DB: %v", err)
Expand Down

0 comments on commit 8f063b8

Please sign in to comment.