添加修改表编码

pull/25/merge
lifei6671 2017-05-01 20:24:43 +08:00
parent c36faea699
commit e282f3442b
3 changed files with 18 additions and 2 deletions

View File

@ -46,12 +46,24 @@ func RegisterModel() {
new(models.Document),
new(models.Attachment),
new(models.Logger),
new(models.CommentVote),
)
}
func Initialization() {
o := orm.NewOrm()
o.Raw("alter table "+models.NewMember().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewBook().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewRelationship().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewComment().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table " +models.NewOption().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewDocument().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewAttachment().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewLogger().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
o.Raw("alter table "+models.NewCommentVote().TableNameWithPrefix()+" convert to character set utf8mb4_general_ci;").Exec()
options := []models.Option {
{ OptionName: "ENABLED_CAPTCHA", OptionValue: "false", OptionTitle:"是否启用验证码"},
{ OptionName: "ENABLED_REGISTER",OptionValue:"false",OptionTitle:"是否启用注册"},

View File

@ -32,7 +32,9 @@ func (u *CommentVote) TableUnique() [][]string {
[]string{"comment_id", "vote_member_id"},
}
}
func NewCommentVote() *CommentVote {
return &CommentVote{}
}
func (m *CommentVote) InsertOrUpdate() (*CommentVote,error) {
o := orm.NewOrm()

View File

@ -37,7 +37,9 @@ func (m *Logger) TableNameWithPrefix() string {
return conf.GetDatabasePrefix() + m.TableName()
}
func NewLogger() *Logger {
return &Logger{}
}