package models

import (
	"log"

	"github.com/gobuffalo/envy"
	"github.com/gobuffalo/packr/v2"
	"github.com/gobuffalo/pop"
	"github.com/nleof/goyesql"
)

// DB is a connection to your database to be used
// throughout your application.
var DB *pop.Connection

// Q is a map of SQL queries
var Q goyesql.Queries

func init() {
	var err error
	env := envy.Get("GO_ENV", "development")
	DB, err = pop.Connect(env)
	if err != nil {
		log.Fatal(err)
	}
	pop.Debug = env == "development"
	box := packr.New("./sql", "./sql")
	sql, err := box.MustBytes("queries.sql")
	if err != nil {
		log.Fatal(err)
	}
	Q = goyesql.MustParseBytes(sql)
}

package models

import (
	"log"

	"github.com/gobuffalo/envy"
	"github.com/gobuffalo/packr/v2"
	"github.com/gobuffalo/pop"
	"github.com/nleof/goyesql"
)

// DB is a connection to your database to be used
// throughout your application.
var DB *pop.Connection

// Q is a map of SQL queries
var Q goyesql.Queries

func init() {
	var err error
	env := envy.Get("GO_ENV", "development")
	DB, err = pop.Connect(env)
	if err != nil {
		log.Fatal(err)
	}
	pop.Debug = env == "development"
	box := packr.New("./sql", "./sql")
	sql, err := box.Find("queries.sql")
	if err != nil {
		log.Fatal(err)
	}
	Q = goyesql.MustParseBytes(sql)
}

Fix deprecated API warning in buffalo packr
Fix deprecated API warning in buffalo packr

Signed-off-by: Elliot Murphy <014ce8fab4ab9f8a957bfe9f974379093994de97@users.noreply.github.com>
