Skip to content

Commit

Permalink
Update gorm
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisommore committed Jul 6, 2022
1 parent 186f5d5 commit 93b3a68
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 182 deletions.
2 changes: 1 addition & 1 deletion api/middleware/auth/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/gin-gonic/gin"
jwt "github.com/golang-jwt/jwt/v4"
"github.com/jinzhu/gorm"
"gorm.io/gorm"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion api/v1/claimRole/claimrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"gorm.io/gorm"
)

// ApplyRoutes applies router to gin Router
Expand Down
2 changes: 1 addition & 1 deletion api/v1/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func patchProfile(c *gin.Context) {
walletAddress := c.GetString("walletAddress")
result := db.Model(&models.User{}).
Where("wallet_address = ?", walletAddress).
Update(requestBody)
Updates(requestBody)
if result.Error != nil {
httphelper.ErrResponse(c, http.StatusInternalServerError, "Unexpected error occured")

Expand Down
2 changes: 1 addition & 1 deletion api/v1/roleId/roleid.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/TheLazarusNetwork/marketplace-engine/util/pkg/logwrapper"

"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"gorm.io/gorm"
)

// ApplyRoutes applies router to gin Router
Expand Down
19 changes: 12 additions & 7 deletions config/dbconfig/dbconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (

"github.com/TheLazarusNetwork/marketplace-engine/util/pkg/envutil"

"github.com/jinzhu/gorm"

_ "github.com/jinzhu/gorm/dialects/postgres"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)

var db *gorm.DB
Expand All @@ -27,17 +26,23 @@ func GetDb() *gorm.DB {
port = envutil.MustGetEnv("DB_PORT")
)

psqlInfo := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable port=%s",
dns := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable port=%s",
host, username, password, dbname, port)

var err error
db, err = gorm.Open("postgres", psqlInfo)
db, err = gorm.Open(postgres.New(postgres.Config{
DSN: dns,
}))
if err != nil {
log.Fatal("failed to connect database", err)
}

if err = db.DB().Ping(); err != nil {
sqlDb, err := db.DB()
if err != nil {
log.Fatal("failed to ping database", err)
}
if err = sqlDb.Ping(); err != nil {
log.Fatal("failed to ping database", err)
}

return db
}
2 changes: 1 addition & 1 deletion config/dbconfig/dbinit/dbinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func Init() error {
db := dbconfig.GetDb()
err := db.AutoMigrate(&models.FlowId{}, &models.User{}, &models.Role{}, &Org.Org{}).Error
err := db.AutoMigrate(&models.User{}, &models.FlowId{}, &models.Role{}, &Org.Org{})
if err != nil {
log.Fatal(err)
return err
Expand Down
16 changes: 2 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,26 @@ module github.com/TheLazarusNetwork/marketplace-engine
go 1.16

require (
github.com/Azure/azure-pipeline-go v0.2.2 // indirect
github.com/Azure/azure-storage-blob-go v0.7.0 // indirect
github.com/Azure/go-autorest/autorest/adal v0.8.0 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
github.com/btcsuite/btcd v0.22.1
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/ethereum/go-ethereum v1.10.18
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.8.0
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/assert/v2 v2.0.1
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0 // indirect
github.com/ipfs/go-cid v0.2.0 // indirect
github.com/ipfs/go-ipfs-api v0.3.0
github.com/ipfs/go-ipfs-files v0.1.1 // indirect
github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.4.0
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
github.com/lib/pq v1.10.6
github.com/libp2p/go-libp2p-core v0.16.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/multiformats/go-base32 v0.0.4 // indirect
github.com/multiformats/go-multiaddr v0.5.0 // indirect
Expand All @@ -47,12 +38,9 @@ require (
github.com/tyler-smith/go-bip39 v1.1.0
github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 // indirect
gotest.tools v2.2.0+incompatible // indirect
gorm.io/driver/postgres v1.3.8
gorm.io/gorm v1.23.7
lukechampine.com/blake3 v1.1.7 // indirect
)
Loading

0 comments on commit 93b3a68

Please sign in to comment.