Skip to content

Commit

Permalink
Unification in home page
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-jagruti-a committed Dec 18, 2023
1 parent 9e51fa3 commit 538039b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy-backend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: DeployBackendDev

on:
push:
branches:
- "master"


jobs:
deploy-backend-dev:
Expand Down
2 changes: 1 addition & 1 deletion db/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/jmoiron/sqlx v1.3.5
github.com/go-sql-driver/mysql v1.6.0
github.com/lib/pq v1.2.0
github.com/sirupsen/logrus v1.9.0
)

Expand Down
18 changes: 12 additions & 6 deletions db/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"os"
"strings"
"time"
_ "github.com/go-sql-driver/mysql"

"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/reflectx"
_ "github.com/lib/pq"
log "github.com/sirupsen/logrus"
)

Expand All @@ -18,13 +19,13 @@ func NewSql() *sqlx.DB {
username := os.Getenv("DB_USERNAME")

if username == "" {
username = "root"
username = "postgres"
}

password := os.Getenv("DB_PASSWORD")

if password == "" {
password = "root"
password = "postgres"
}

host := os.Getenv("DB_HOST")
Expand All @@ -36,16 +37,21 @@ func NewSql() *sqlx.DB {
port := os.Getenv("DB_PORT")

if port == "" {
port = "3306"
port = "5432"
}

name := os.Getenv("DB_NAME")

if name == "" {
name = "website_admin"
name = "postgres"
}

sslmode := "require"
if os.Getenv("DB_ENV") == "test" {
sslmode = "disable"
}

db = sqlx.MustConnect("mysql", username+":"+password+"@("+host+":"+port+")/"+name)
db = sqlx.MustConnect("postgres", "postgres://"+username+":"+password+"@"+host+":"+port+"/"+name+"?sslmode="+sslmode)

db.Mapper = reflectx.NewMapperFunc("json", strings.ToLower)
db.SetConnMaxLifetime(time.Minute * 1)
Expand Down

0 comments on commit 538039b

Please sign in to comment.