我有一个用 Go 编写的 API,我有以下一组模型......
type User struct {
gorm.Model
ID string `sql:"type:varchar(36);primary key"`
Name string
Password string
Email string
Content []Content
Location string
Tracks []Track
Avatar string
BgImg string
Artists []Artist
}
type Artist struct {
gorm.Model
ID string `sql:"type:varchar(36);primary key"`
}
type Content struct {
gorm.Model
ID string `sql:"type:varchar(36);primary key"`
}
type Track struct {
gorm.Model
ID string `sql:"type:varchar(36);primary key"`
}
在我的main.go
文件中,我正在初始化我的数据库......
drivers.DB().CreateTable(&models.User{})
drivers.DB().CreateTable(&models.Artist{})
drivers.DB().CreateTable(&models.Content{})
drivers.DB().CreateTable(&models.Track{})
但我得到了错误......
{
"_message": {
"Severity": "ERROR",
"Code": "42P01",
"Message": "relation \"users\" does not exist",
"Detail": "",
"Hint": "",
"Position": "15",
"InternalPosition": "",
"InternalQuery": "",
"Where": "",
"Schema": "",
"Table": "",
"Column": "",
"DataTypeName": "",
"Constraint": "",
"File": "parse_relation.c",
"Line": "1159",
"Routine": "parserOpenTable"
}
}