15 Star 61 Fork 10

e9ab98e991ab/GoBooks

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
migrations.go 1.14 KB
Copy Edit Raw Blame History
高鑫 authored 2020-01-03 09:39 +08:00 . commit
package models
import (
"time"
"gitee.com/Godfeer/GoBooks/conf"
"github.com/astaxie/beego/orm"
)
type Migration struct {
MigrationId int `orm:"column(migration_id);pk;auto;unique;" json:"migration_id"`
Name string `orm:"column(name);size(500)" json:"name"`
Statements string `orm:"column(statements);type(text);null" json:"statements"`
Status string `orm:"column(status);default(update)" json:"status"`
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
Version int64 `orm:"type(bigint);column(version);unique" json:"version"`
}
// TableName 获取对应数据库表名.
func (m *Migration) TableName() string {
return "migrations"
}
// TableEngine 获取数据使用的引擎.
func (m *Migration) TableEngine() string {
return "INNODB"
}
func (m *Migration) TableNameWithPrefix() string {
return conf.GetDatabasePrefix() + m.TableName()
}
func NewMigration() *Migration {
return &Migration{}
}
func (m *Migration) FindFirst() (*Migration, error) {
o := orm.NewOrm()
err := o.QueryTable(m.TableNameWithPrefix()).OrderBy("-migration_id").One(m)
return m, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Godfeer/GoBooks.git
git@gitee.com:Godfeer/GoBooks.git
Godfeer
GoBooks
GoBooks
cbd8ecaa8838

Search