mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
upgraded migrations and context usage
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user