Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
remove postgress
Browse files Browse the repository at this point in the history
  • Loading branch information
Erez Fishhimer committed Nov 21, 2022
1 parent f7042c8 commit d6d6272
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions backend/pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
package database

import (
"fmt"
"os"

log "github.com/sirupsen/logrus"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
Expand All @@ -31,7 +29,6 @@ const (
)

const (
DBDriverTypePostgres = "POSTGRES"
DBDriverTypeLocal = "LOCAL"
)

Expand Down Expand Up @@ -94,8 +91,6 @@ func initDataBase(config *DBConfig) *gorm.DB {
func initDB(config *DBConfig, dbDriver string, dbLogger logger.Interface) *gorm.DB {
var db *gorm.DB
switch dbDriver {
case DBDriverTypePostgres:
db = initPostgres(config, dbLogger)
case DBDriverTypeLocal:
db = initSqlite(dbLogger)
default:
Expand All @@ -111,20 +106,6 @@ func createAllViews(db *gorm.DB) {
func dropAllViews(db *gorm.DB) {
}

func initPostgres(config *DBConfig, dbLogger logger.Interface) *gorm.DB {
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=UTC",
config.DBHost, config.DBUser, config.DBPassword, config.DBName, config.DBPort)

db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{
Logger: dbLogger,
})
if err != nil {
log.Fatalf("Failed to open %s db: %v", config.DBName, err)
}

return db
}

func initSqlite(dbLogger logger.Interface) *gorm.DB {
cleanLocalDataBase(localDBPath)

Expand Down

0 comments on commit d6d6272

Please sign in to comment.