package auth import ( "time" "gorm.io/gorm" "wucher/internal/shared/pkg/uuidv7" ) type UserRole struct { ID []byte `gorm:"type:binary(16);primaryKey;column:id"` UserID []byte `gorm:"type:binary(16);index;uniqueIndex:ux_user_role;not null;column:user_id"` RoleID []byte `gorm:"type:binary(16);index;uniqueIndex:ux_user_role;not null;column:role_id"` CreatedAt time.Time CreatedBy []byte `gorm:"type:binary(16);column:created_by"` UpdatedAt time.Time UpdatedBy []byte `gorm:"type:binary(16);column:updated_by"` } func (UserRole) TableName() string { return "user_roles" } func (ur *UserRole) BeforeCreate(tx *gorm.DB) error { if len(ur.ID) == 0 { ur.ID = uuidv7.MustBytes() } return nil }