Merge pull request #5436 from reasonerjt/creation-time-sql

Set default creation_time and update_time at model
This commit is contained in:
Wenkai Yin 2018-07-31 13:51:44 +08:00 committed by GitHub
commit 3739a96d30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 12 deletions

View File

@ -31,8 +31,8 @@ type Label struct {
Level string `orm:"column(level)" json:"-"` Level string `orm:"column(level)" json:"-"`
Scope string `orm:"column(scope)" json:"scope"` Scope string `orm:"column(scope)" json:"scope"`
ProjectID int64 `orm:"column(project_id)" json:"project_id"` ProjectID int64 `orm:"column(project_id)" json:"project_id"`
CreationTime time.Time `orm:"column(creation_time)" json:"creation_time"` CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
UpdateTime time.Time `orm:"column(update_time)" json:"update_time"` UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
Deleted bool `orm:"column(deleted)" json:"deleted"` Deleted bool `orm:"column(deleted)" json:"deleted"`
} }
@ -74,8 +74,8 @@ type ResourceLabel struct {
ResourceID int64 `orm:"column(resource_id)"` ResourceID int64 `orm:"column(resource_id)"`
ResourceName string `orm:"column(resource_name)"` ResourceName string `orm:"column(resource_name)"`
ResourceType string `orm:"column(resource_type)"` ResourceType string `orm:"column(resource_type)"`
CreationTime time.Time `orm:"column(creation_time)"` CreationTime time.Time `orm:"column(creation_time);auto_now_add"`
UpdateTime time.Time `orm:"column(update_time)"` UpdateTime time.Time `orm:"column(update_time);auto_now"`
} }
// TableName ... // TableName ...

View File

@ -38,7 +38,7 @@ type ProjectMetadata struct {
ProjectID int64 `orm:"column(project_id)" json:"project_id"` ProjectID int64 `orm:"column(project_id)" json:"project_id"`
Name string `orm:"column(name)" json:"name"` Name string `orm:"column(name)" json:"name"`
Value string `orm:"column(value)" json:"value"` Value string `orm:"column(value)" json:"value"`
CreationTime time.Time `orm:"column(creation_time)" json:"creation_time"` CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
UpdateTime time.Time `orm:"column(update_time)" json:"update_time"` UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
Deleted bool `orm:"column(deleted)" json:"deleted"` Deleted bool `orm:"column(deleted)" json:"deleted"`
} }

View File

@ -27,8 +27,8 @@ type Project struct {
ProjectID int64 `orm:"pk;auto;column(project_id)" json:"project_id"` ProjectID int64 `orm:"pk;auto;column(project_id)" json:"project_id"`
OwnerID int `orm:"column(owner_id)" json:"owner_id"` OwnerID int `orm:"column(owner_id)" json:"owner_id"`
Name string `orm:"column(name)" json:"name"` Name string `orm:"column(name)" json:"name"`
CreationTime time.Time `orm:"column(creation_time)" json:"creation_time"` CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
UpdateTime time.Time `orm:"column(update_time)" json:"update_time"` UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
Deleted bool `orm:"column(deleted)" json:"deleted"` Deleted bool `orm:"column(deleted)" json:"deleted"`
OwnerName string `orm:"-" json:"owner_name"` OwnerName string `orm:"-" json:"owner_name"`
Togglable bool `orm:"-" json:"togglable"` Togglable bool `orm:"-" json:"togglable"`

View File

@ -38,8 +38,8 @@ type User struct {
HasAdminRole bool `orm:"column(sysadmin_flag)" json:"has_admin_role"` HasAdminRole bool `orm:"column(sysadmin_flag)" json:"has_admin_role"`
ResetUUID string `orm:"column(reset_uuid)" json:"reset_uuid"` ResetUUID string `orm:"column(reset_uuid)" json:"reset_uuid"`
Salt string `orm:"column(salt)" json:"-"` Salt string `orm:"column(salt)" json:"-"`
CreationTime time.Time `orm:"column(creation_time)" json:"creation_time"` CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
UpdateTime time.Time `orm:"column(update_time)" json:"update_time"` UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
GroupList []*UserGroup `orm:"-" json:"-"` GroupList []*UserGroup `orm:"-" json:"-"`
} }

View File

@ -25,8 +25,8 @@ type WatchItem struct {
Namespace string `orm:"column(namespace)" json:"namespace"` Namespace string `orm:"column(namespace)" json:"namespace"`
OnDeletion bool `orm:"column(on_deletion)" json:"on_deletion"` OnDeletion bool `orm:"column(on_deletion)" json:"on_deletion"`
OnPush bool `orm:"column(on_push)" json:"on_push"` OnPush bool `orm:"column(on_push)" json:"on_push"`
CreationTime time.Time `orm:"column(creation_time)" json:"creation_time"` CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
UpdateTime time.Time `orm:"column(update_time)" json:"update_time"` UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
} }
//TableName ... //TableName ...