Skip to content

Commit

Permalink
♻️ refactor: Update database migration setup in migration/migration.go
Browse files Browse the repository at this point in the history
Refined the database migration setup in migration/migration.go. Enhanced error handling and streamlined the database connection setup process for increased efficiency and reliability of migrations.

Related issue: #66
  • Loading branch information
yuminn-k committed Mar 6, 2024
1 parent 3504ce7 commit 8db56ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"
)

func InitDB() *gorm.DB {
func InitDB() (*gorm.DB, error) {
user := os.Getenv("MYSQL_USER")
pass := os.Getenv("MYSQL_PASSWORD")
dbName := os.Getenv("MYSQL_DATABASE")
Expand Down Expand Up @@ -40,7 +40,7 @@ func InitDB() *gorm.DB {
sqlDB.SetMaxOpenConns(100)
sqlDB.SetConnMaxLifetime(time.Hour)

return db
return db, nil
}

func Migrate(db *gorm.DB) {
Expand Down

0 comments on commit 8db56ea

Please sign in to comment.