type Contact struct {
gorm.Model
PersonID sql.NullInt64
}
type Person struct {
gorm.Model
}
I am trying to use gorm with mysql in the previuos code but I have the following problem:
I want:
- Use
sql.NullInt64
to work easily with null values. - Use the base model definition
gorm.Model
, including fieldsID
,CreatedAt
,UpdatedAt
,DeletedAt
. - Add a constraint
Db.Model(&models.Contact{}).AddForeignKey
.
My problem:
Person.ID
become"int(10)"
in mysql.Contact.PersonID
become"bigint(20)"
- MySql need the same type for pk and fk.
Some body can help me to solve this?