From 51655a09a1f19fb9042f94db46fd9a4e0a0bb1b0 Mon Sep 17 00:00:00 2001 From: naiba Date: Mon, 24 Oct 2022 04:12:51 +0000 Subject: [PATCH] gorm: CreatedAt index --- model/common.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/model/common.go b/model/common.go index a3628da..3341e54 100644 --- a/model/common.go +++ b/model/common.go @@ -1,8 +1,9 @@ package model import ( - "gorm.io/gorm" "time" + + "gorm.io/gorm" ) const CtxKeyAuthorizedUser = "ckau" @@ -11,7 +12,7 @@ const CacheKeyOauth2State = "p:a:state" type Common struct { ID uint64 `gorm:"primaryKey"` - CreatedAt time.Time `gorm:"<-:create"` + CreatedAt time.Time `gorm:"index;<-:create"` UpdatedAt time.Time `gorm:"autoUpdateTime"` DeletedAt gorm.DeletedAt `gorm:"index"` }