Milen/db/db.go

26 lines
349 B
Go

2020-05-11 05:30:07 +07:00
package db
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
var db *gorm.DB
func init() {
var err error
db, err = gorm.Open("sqlite3", "bot.db")
if err != nil {
panic(err)
}
db.AutoMigrate(&ReactRole{})
db.AutoMigrate(&PlayerLevel{})
2020-05-11 05:30:07 +07:00
}
func Close() {
2020-05-31 03:23:23 +07:00
err := db.Close()
if err != nil {
panic(err)
}
2020-05-11 05:30:07 +07:00
}