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