pusher/biz/dal/postgres/init.go

28 lines
456 B
Go
Raw Normal View History

2024-05-20 17:57:25 +08:00
package postgres
2024-05-17 18:02:10 +08:00
import (
"gitea.timerzz.com/kedaya_haitao/pusher/conf"
2024-05-20 17:57:25 +08:00
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
2024-05-17 18:02:10 +08:00
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
var (
DB *gorm.DB
err error
)
func Init() {
DB, err = gorm.Open(postgres.Open(conf.GetConf().DB.DSN),
&gorm.Config{
PrepareStmt: true,
SkipDefaultTransaction: true,
},
)
if err != nil {
panic(err)
}
2024-05-20 17:57:25 +08:00
_ = DB.AutoMigrate(&config.PusherConfig{})
2024-05-17 18:02:10 +08:00
}