From e2046d0d39d9914473fe7b8fae3b18246ed133ce Mon Sep 17 00:00:00 2001 From: "henry.chen" Date: Sun, 25 Jul 2021 10:45:33 +0800 Subject: [PATCH] fix: sqlite error --- .gitignore | 1 + conf/app.yml | 4 ++-- pkg/model/account.go | 10 +++++----- pkg/model/article.go | 6 +++--- pkg/model/series.go | 10 +++++----- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index aa4e7b7..5415542 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.dylib *.DS_Store *.tar.gz +*.db backend # Test binary, built with `go test -c` diff --git a/conf/app.yml b/conf/app.yml index da94050..5785535 100644 --- a/conf/app.yml +++ b/conf/app.yml @@ -1,7 +1,7 @@ appname: eiblog database: - driver: postgres - source: host=localhost port=5432 user=postgres dbname=eiblog sslmode=disable password=MTI3LjAuMC4x + driver: sqlite + source: ./eiblog.db eshost: eiblogapp: mode: diff --git a/pkg/model/account.go b/pkg/model/account.go index e627194..4edcc25 100644 --- a/pkg/model/account.go +++ b/pkg/model/account.go @@ -13,9 +13,9 @@ type Account struct { PhoneN string `gorm:"column:phone_n;not null" bson:"phone_n"` // 手机号 Address string `gorm:"column:address;not null" bson:"address"` // 地址信息 - LogoutAt time.Time `gorm:"column:logout_at;not null" bson:"logout_at"` // 登出时间 - LoginIP string `gorm:"column:login_ip;not null" bson:"login_ip"` // 最近登录IP - LoginUA string `gorm:"column:login_ua;not null" bson:"login_ua"` // 最近登录IP - LoginAt time.Time `gorm:"column:login_at;default:now()" bson:"login_at"` // 最近登录时间 - CreatedAt time.Time `gorm:"column:created_at;default:now()" bson:"created_at"` // 创建时间 + LogoutAt time.Time `gorm:"column:logout_at;not null" bson:"logout_at"` // 登出时间 + LoginIP string `gorm:"column:login_ip;not null" bson:"login_ip"` // 最近登录IP + LoginUA string `gorm:"column:login_ua;not null" bson:"login_ua"` // 最近登录IP + LoginAt time.Time `gorm:"column:login_at;default:current_timestamp" bson:"login_at"` // 最近登录时间 + CreatedAt time.Time `gorm:"column:created_at;default:current_timestamp" bson:"created_at"` // 创建时间 } diff --git a/pkg/model/article.go b/pkg/model/article.go index e4a2a51..f9d77fb 100644 --- a/pkg/model/article.go +++ b/pkg/model/article.go @@ -21,9 +21,9 @@ type Article struct { Tags pq.StringArray `gorm:"column:tags;type:text[]" bson:"tags"` // tags IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿 - DeletedAt time.Time `gorm:"column:deleted_at;not null" bson:"deleted_at"` // 删除时间 - UpdatedAt time.Time `gorm:"column:updated_at;default:now()" bson:"updated_at"` // 更新时间 - CreatedAt time.Time `gorm:"column:created_at;default:now()" bson:"created_at"` // 创建时间 + DeletedAt time.Time `gorm:"column:deleted_at;not null" bson:"deleted_at"` // 删除时间 + UpdatedAt time.Time `gorm:"column:updated_at;default:current_timestamp" bson:"updated_at"` // 更新时间 + CreatedAt time.Time `gorm:"column:created_at;default:current_timestamp" bson:"created_at"` // 创建时间 Header string `gorm:"-" bson:"-"` // header Excerpt string `gorm:"-" bson:"-"` // 预览信息 diff --git a/pkg/model/series.go b/pkg/model/series.go index ed48840..5751e84 100644 --- a/pkg/model/series.go +++ b/pkg/model/series.go @@ -5,11 +5,11 @@ import "time" // Serie 专题 type Serie struct { - ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID - Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 缩略名 - Name string `gorm:"column:name;not null" bson:"name"` // 专题名 - Desc string `gorm:"column:desc;not null" bson:"desc"` // 专题描述 - CreatedAt time.Time `gorm:"column:created_at;default:now()" bson:"created_at"` // 创建时间 + ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID + Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 缩略名 + Name string `gorm:"column:name;not null" bson:"name"` // 专题名 + Desc string `gorm:"column:desc;not null" bson:"desc"` // 专题描述 + CreatedAt time.Time `gorm:"column:created_at;default:current_timestamp" bson:"created_at"` // 创建时间 Articles SortedArticles `gorm:"-" bson:"-"` // 专题下的文章 }