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.
31 lines
318 B
31 lines
318 B
4 months ago
|
package models
|
||
|
|
||
|
import (
|
||
|
"ginCms/utils"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
// Init 初始化模型
|
||
|
func Init() {
|
||
|
// migrate
|
||
|
migrate()
|
||
|
|
||
|
// seed
|
||
|
seed()
|
||
|
}
|
||
|
|
||
|
// 表结构迁移
|
||
|
func migrate() {
|
||
|
// 自动迁移
|
||
|
if err := utils.DB().AutoMigrate(
|
||
|
&Role{},
|
||
|
); err != nil {
|
||
|
log.Fatalln(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 数据填充
|
||
|
func seed() {
|
||
|
roleSeed()
|
||
|
}
|