fix: roles query failing due to composite primary key in GORM many2many
Some checks failed
CI / Build & Test (push) Failing after 32s

Add explicit foreignKey/references tags to Role.Permissions association
so GORM uses only ID (not composite ID+TenantID) for the join table.
This commit is contained in:
MengStack Dev 2026-10-03 04:25:51 +08:00
parent 485ae9b329
commit 66ec9afe77

View File

@ -11,7 +11,7 @@ type Role struct {
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`
Permissions []Permission `json:"permissions,omitempty" gorm:"many2many:role_permissions;"` Permissions []Permission `json:"permissions,omitempty" gorm:"many2many:role_permissions;foreignKey:ID;references:ID;joinForeignKey:RoleID;joinReferences:PermissionID"`
} }
func (Role) TableName() string { func (Role) TableName() string {