This commit is contained in:
[Valentino Heman Budiarto]
2026-06-05 19:46:48 +07:00
parent 0a8ced6490
commit 16075c670a
2 changed files with 51 additions and 37 deletions
+4 -4
View File
@@ -4,8 +4,8 @@ import (
"fmt"
"log"
"os"
"strings" // TAMBAHAN: Untuk membersihkan spasi/enter gaib
"s-class-backend/models"
"strings"
"github.com/joho/godotenv"
"gorm.io/driver/postgres"
@@ -32,13 +32,13 @@ func ConnectDatabase() {
fmt.Printf("[DEBUG] Host: %s | Port: %s | User: %s | DB: %s\n", dbHost, dbPort, dbUser, dbName)
fmt.Printf("[DEBUG] Panjang karakter password yang dibaca Golang: %d\n", len(dbPassword))
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Jakarta",
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Jakarta",
dbHost, dbUser, dbPassword, dbName, dbPort)
database, err := gorm.Open(postgres.Open(dsn), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
})
if err != nil {
fmt.Println("[ERROR FATAL KONEKSI DB]:", err)
panic("Gagal koneksi ke database!")
@@ -54,4 +54,4 @@ func ConnectDatabase() {
fmt.Println("Sukses terkoneksi ke Database PostgreSQL!")
DB = database
}
}