Using sqlMigrate from sacrebleu-api
This commit is contained in:
parent
1b00ac0528
commit
d1b9dba472
2 changed files with 3 additions and 8 deletions
5
main.go
5
main.go
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue