|
|
@ -1,7 +1,6 @@ |
|
|
|
package initializers |
|
|
|
package initializers |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"log" |
|
|
|
|
|
|
|
"os" |
|
|
|
"os" |
|
|
|
|
|
|
|
|
|
|
|
"gorm.io/driver/postgres" |
|
|
|
"gorm.io/driver/postgres" |
|
|
@ -12,10 +11,10 @@ var DB *gorm.DB |
|
|
|
|
|
|
|
|
|
|
|
func ConnectToDB() { |
|
|
|
func ConnectToDB() { |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
dsn := os.Getenv("DB_URL") |
|
|
|
dsn := os.Getenv("DB") |
|
|
|
DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{}) |
|
|
|
DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{}) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Fatal("Failed to connect to database") |
|
|
|
panic("Failed to connect to database") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|