Archived
1
0
Fork 0
This repository has been archived on 2024-12-18. You can view files and clone it, but cannot push or open issues or pull requests.
flexassistant/db.go

23 lines
491 B
Go
Raw Normal View History

package main
import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
// NewDatabase creates a SQLite database object from a file name
func NewDatabase(filename string) (*gorm.DB, error) {
return gorm.Open(sqlite.Open(filename), &gorm.Config{})
}
// CreateDatabaseObjects creates database relations
func CreateDatabaseObjects(db *gorm.DB) error {
if err := db.AutoMigrate(&Miner{}); err != nil {
return err
}
if err := db.AutoMigrate(&Pool{}); err != nil {
return err
}
return nil
}