upgraded migrations and context usage

This commit is contained in:
Fran Jurmanović
2021-07-03 00:01:25 +02:00
parent 4189a0d333
commit 788ff3a146
33 changed files with 321 additions and 251 deletions

View File

@@ -1,17 +1,19 @@
package db
import (
"context"
"fmt"
"wallet-api/pkg/utl/common"
"github.com/go-pg/pg/v10"
)
func CreateConnection(dbUrl string) *pg.DB {
func CreateConnection(dbUrl string, ctx context.Context) *pg.DB {
opt, err := pg.ParseURL(dbUrl)
common.CheckError(err)
conn := pg.Connect(opt)
db := conn.WithContext(ctx)
fmt.Println("Successfully connected!")
return conn
return db
}