Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time.Duration for postgresql AutoMigrate failed #3503

Closed
gleke opened this issue Sep 21, 2020 · 2 comments
Closed

time.Duration for postgresql AutoMigrate failed #3503

gleke opened this issue Sep 21, 2020 · 2 comments
Assignees
Labels

Comments

@gleke
Copy link

gleke commented Sep 21, 2020

time.Duration AutoMigrate failed

Description

type SysOperationRecord struct {
gorm.Model
Ip string json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"
Method string json:"method" form:"method" gorm:"column:method;comment:请求方法"
Path string json:"path" form:"path" gorm:"column:path;comment:请求路径"
Status int json:"status" form:"status" gorm:"column:status;comment:请求状态"
Latency time.Duration json:"latency" form:"latency" gorm:"column:latency;comment:延迟"
Agent string json:"agent" form:"agent" gorm:"column:agent;comment:代理"
ErrorMessage string json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"
Body string json:"body" form:"body" gorm:"column:body;comment:请求Body"
Resp string json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"
UserID int json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"
User SysUser json:"user"
}

err := db.AutoMigrate(
model.SysOperationRecord{},
)

failed :SQLSTATE 42P01

@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Sep 21, 2020
@github-actions
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@jinzhu
Copy link
Member

jinzhu commented Sep 22, 2020

time.Duration is not supported as database/sql doesn't support it, have to implemented the Scanner, Valuer interface for customized data types.

@jinzhu jinzhu closed this as completed Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants