Skip to content

Commit

Permalink
Use different pointer for MigrationDB
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Mar 31, 2022
1 parent 70bfe15 commit 97d1542
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions dbs/migration_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func MigrationRequests(mid int64) ([]MigrationRequest, error) {
Error(
err,
TransactionErrorCode,
"",
"unable to obtain MigrationDB transaction",
"dbs.migration_requests.MigrationRequests")
}
defer tx.Rollback()
Expand All @@ -167,7 +167,8 @@ func MigrationRequests(mid int64) ([]MigrationRequest, error) {
}
rows, err := tx.Query(stm, args...)
if err != nil {
return records, Error(err, QueryErrorCode, "", "dbs.migration_requests.MigrationRequests")
msg := fmt.Sprintf("fail to execute %s", stm)
return records, Error(err, QueryErrorCode, msg, "dbs.migration_requests.MigrationRequests")
}
defer rows.Close()
for rows.Next() {
Expand Down
11 changes: 6 additions & 5 deletions web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ import (
_ "net/http/pprof"

"github.com/dmwm/cmsauth"
"github.com/dmwm/dbs2go/dbs"
dbsGraphQL "github.com/dmwm/dbs2go/graphql"
"github.com/dmwm/dbs2go/utils"
validator "github.com/go-playground/validator/v10"
"github.com/gorilla/csrf"
"github.com/gorilla/mux"
graphql "github.com/graph-gophers/graphql-go"
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
"github.com/vkuznet/auth-proxy-server/logging"
"github.com/dmwm/dbs2go/dbs"
dbsGraphQL "github.com/dmwm/dbs2go/graphql"
"github.com/dmwm/dbs2go/utils"

// imports for supported DB drivers
// go-oci8 oracle driver
Expand Down Expand Up @@ -387,11 +387,12 @@ func Server(configFile string) {
// setup MigrationDB access
if Config.ServerType == "DBSMigration" || Config.ServerType == "DBSMigrate" {
log.Println("parse Config.MigrationDBFile:", Config.MigrationDBFile)
dbtype, dburi, dbowner = dbs.ParseDBFile(Config.MigrationDBFile)
db, dberr = dbInit(dbtype, dburi)
dbtype, dburi, dbowner := dbs.ParseDBFile(Config.MigrationDBFile)
db, dberr := dbInit(dbtype, dburi)
if dberr != nil {
log.Fatal(dberr)
}
log.Printf("obtain MigrationDB dburi for %s and %s", dbtype, dbowner)
dbs.MigrationDB = db
defer dbs.MigrationDB.Close()
}
Expand Down

0 comments on commit 97d1542

Please sign in to comment.