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
Julien Riou f51679193a
feat: Initial release (1.0)
Signed-off-by: Julien Riou <julien@riou.xyz>
2021-10-06 19:07:41 +02:00

22 lines
491 B
Go

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
}