How to make foreign key using gorm

I have those two models:

User model:

type User struct {
    Email    string `gorm:"column:email" json:"email"`
    Password string `gorm:"column:password" json:"-"`

func (User) TableName() string {
    return "t_user"

User info model:

type UserInfo struct {
    UID       uint   `gorm:"column:u_id" json:"-"`
    FirstName string `gorm:"column:first_name" json:"first_name"`
    LastName  string `gorm:"column:last_name" json:"last_name"`
    Phone     string `gorm:"column:phone" json:"phone"`
    Address   string `gorm:"column:address" json:"address"`

func (UserInfo) TableName() string {
    return "t_user_info"

and I want to make UID related to the id of the user table.

I did try what gorm wrote on the documentation, but without success:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.