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

View file

@ -49,12 +49,6 @@ func SQLDatabase(conf *Conf) *gorm.DB {
return 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 //Check for a record in the SQL database
func sqlCheckForRecord(redisKey string, dKey string, entry types.Record) ([]types.Record, bool) { func sqlCheckForRecord(redisKey string, dKey string, entry types.Record) ([]types.Record, bool) {
var records []types.Record var records []types.Record