You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
devops/entities/init.go

33 lines
480 B

package entities
import (
"encoding/gob"
"log"
"gorm.io/gorm"
)
func Init(db *gorm.DB) error {
err := db.AutoMigrate(
&User{},
&Project{},
&Build{},
&BuildStep{},
)
if err != nil {
log.Fatalln(err)
}
err = db.Model(&User{}).FirstOrCreate(&User{
ID: 1,
Username: "admin",
RawPassword: "111111",
}, User{ID: 1}).Error
if err != nil {
log.Fatalln(err)
}
// 使用 github.com/gorilla/sessions 需要
gob.Register(&User{})
return nil
}