1
0
Fork 0

Remove created at field from most models

This commit is contained in:
Gregory Eremin 2015-03-20 22:32:26 +07:00
parent abd0d96b10
commit ecb95882d6
4 changed files with 13 additions and 12 deletions

View File

@ -9,15 +9,14 @@ type Org struct {
Login string `json:"login"` Login string `json:"login"`
Company string `json:"company"` Company string `json:"company"`
AvatarURL string `json:"avatar_url" db:"avatar_url"` AvatarURL string `json:"avatar_url" db:"avatar_url"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
} }
func (o *Org) Save() { func (o *Org) Save() {
defer measure("SaveOrg", time.Now()) defer measure("SaveOrg", time.Now())
mustExecN(` mustExecN(`
insert into orgs (id, login, company, avatar_url, created_at, updated_at) insert into orgs (id, login, company, avatar_url, updated_at)
values (:id, :login, :company, :avatar_url, now(), now()) values (:id, :login, :company, :avatar_url, now())
on duplicate key update on duplicate key update
login = values(login), login = values(login),
company = values(company), company = values(company),

View File

@ -11,16 +11,20 @@ type Repo struct {
Description string `json:"description"` Description string `json:"description"`
IsPrivate bool `json:"is_private"` IsPrivate bool `json:"is_private"`
IsFork bool `json:"is_fork"` IsFork bool `json:"is_fork"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`
} }
func (r *Repo) Save() { func (r *Repo) Save() {
defer measure("SaveRepo", time.Now()) defer measure("SaveRepo", time.Now())
mustExecN(` mustExecN(`
insert into repos (owner, name, updated_at) insert into repos (org_id, name, description, is_private, is_fork, updated_at)
values (:owner, :name, now()) values (:org_id, :name, :description, :is_private, :is_fork, now())
on duplicate key update on duplicate key update
org_id = values(org_id),
name = values(name),
description = values(description),
is_private = values(is_private),
is_fork = values(is_fork),
updated_at = now() updated_at = now()
`, r) `, r)
} }

View File

@ -10,15 +10,14 @@ type Team struct {
Slug string `json:"slug"` Slug string `json:"slug"`
Name string `json:"name"` Name string `json:"name"`
Permission string `json:"permission"` Permission string `json:"permission"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
} }
func (t *Team) Save() { func (t *Team) Save() {
defer measure("SaveTeam", time.Now()) defer measure("SaveTeam", time.Now())
mustExecN(` mustExecN(`
insert into teams (id, org_id, slug, name, permission, created_at, updated_at) insert into teams (id, org_id, slug, name, permission, updated_at)
values (:id, :org_id, :slug, :name, :permission, now(), now()) values (:id, :org_id, :slug, :name, :permission, now())
on duplicate key update on duplicate key update
slug = values(slug), slug = values(slug),
name = values(name), name = values(name),

View File

@ -9,15 +9,14 @@ type User struct {
Login string `json:"login"` Login string `json:"login"`
Name string `json:"name"` Name string `json:"name"`
AvatarURL string `json:"avatar_url" db:"avatar_url"` AvatarURL string `json:"avatar_url" db:"avatar_url"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
} }
func (u *User) Save() { func (u *User) Save() {
defer measure("SaveUser", time.Now()) defer measure("SaveUser", time.Now())
mustExecN(` mustExecN(`
insert into users (id, login, name, avatar_url, created_at, updated_at) insert into users (id, login, name, avatar_url, updated_at)
values (:id, :login, :name, :avatar_url, now(), now()) values (:id, :login, :name, :avatar_url, now())
on duplicate key update on duplicate key update
login = values(login), login = values(login),
name = values(name), name = values(name),