代码
package model
import "gorm.io/gorm"
type Note struct {
gorm.Model
UserId int
GroupId int
Question string `gorm:"size:256"`
Answers []NoteAnswer
}
type NoteAnswer struct {
gorm.Model
NoteId int
Content string `gorm:"size:256"`
}
db.AutoMigrate(&model.Note{})
db.AutoMigrate(&model.NoteAnswer{})
这样子创建数据表后会在NoteAnswer 里面增加外键和索引,可以怎么限制不创建关键和索引的吗,
The document you expected this should be explained
Expected answer
Comment From: a631807682
https://gorm.io/docs/constraints.html#Foreign-Key-Constraint