Milen/db/db.go

26 lines
349 B
Go

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{})
}
func Close() {
err := db.Close()
if err != nil {
panic(err)
}
}