From d1b9dba4723ab19e6409d3e7502bd48855f83f0b Mon Sep 17 00:00:00 2001
From: Mael GRAMAIN <mael@enpls.org>
Date: Sun, 27 Dec 2020 22:58:20 -0400
Subject: [PATCH] Using sqlMigrate from sacrebleu-api

---
 main.go      | 5 +++--
 utils/sql.go | 6 ------
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/main.go b/main.go
index 0775716..550dc64 100644
--- a/main.go
+++ b/main.go
@@ -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
diff --git a/utils/sql.go b/utils/sql.go
index 8c9657a..0ecb0ee 100644
--- a/utils/sql.go
+++ b/utils/sql.go
@@ -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