Using sqlMigrate from sacrebleu-api

This commit is contained in:
Mael G. 2020-12-27 22:58:20 -04:00
parent 1b00ac0528
commit d1b9dba472
2 changed files with 3 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import (
"strconv"
"github.com/miekg/dns"
"github.com/outout14/sacrebleu-api/api/types"
"github.com/outout14/sacrebleu-dns/core"
"github.com/outout14/sacrebleu-dns/utils"
"github.com/sirupsen/logrus"
@ -40,9 +41,9 @@ func main() {
utils.RedisDatabase(conf)
//Initialize the sql database
utils.SQLDatabase(conf)
db := utils.SQLDatabase(conf)
if *sqlMigration {
utils.SQLMigrate()
types.SQLMigrate(db)
}
//Start the DNS server

View File

@ -49,12 +49,6 @@ func SQLDatabase(conf *Conf) *gorm.DB {
return DB
}
//SQLMigrate : Launch the database migration (creation of tables)
func SQLMigrate() {
logrus.Info("SQL : Database migration launched")
db.AutoMigrate(&types.Record{})
}
//Check for a record in the SQL database
func sqlCheckForRecord(redisKey string, dKey string, entry types.Record) ([]types.Record, bool) {
var records []types.Record