Skip to content

Commit 203b0aa

Browse files
authored
Explicitly add a PK constraint for the many2many association of task-labels (#227)
1 parent ba90785 commit 203b0aa

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

apiserver/internal/models/task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type TaskHistory struct {
3030
}
3131

3232
type TaskLabel struct {
33-
TaskID int `json:"task_id"`
34-
LabelID int `json:"label_id"`
33+
TaskID int `json:"task_id" gorm:"primaryKey"`
34+
LabelID int `json:"label_id" gorm:"primaryKey"`
3535
}
3636

3737
type CreateTaskReq struct {

apiserver/internal/utils/migration/migration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func Migration(db *gorm.DB) error {
1212
models.AppToken{},
1313
models.Label{},
1414
models.Task{},
15+
models.TaskLabel{},
1516
models.TaskHistory{},
1617
models.NotificationSettings{},
1718
models.Notification{},

0 commit comments

Comments
 (0)