Skip to content

Commit

Permalink
Fix DB
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Dec 8, 2023
1 parent 033732a commit 15ac42e
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions api/pkg/di/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ func (container *Container) YugaByteDB() (db *gorm.DB) {
if err = db.Use(tracing.NewPlugin()); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, "cannot use GORM tracing plugin"))
}

sql, err := db.DB()
if err != nil {
container.logger.Fatal(err)
}

sql.SetMaxOpenConns(7)
sql.SetMaxIdleConns(3)
sql.SetConnMaxLifetime(time.Minute * 10)
//
//sql, err := db.DB()
//if err != nil {
// container.logger.Fatal(err)
//}
//
//sql.SetMaxOpenConns(7)
//sql.SetMaxIdleConns(3)
//sql.SetConnMaxLifetime(time.Minute * 10)

//container.logger.Debug(fmt.Sprintf("Running migrations for yugabyte [%T]", db))
//if err = db.AutoMigrate(&entities.Heartbeat{}); err != nil {
Expand Down Expand Up @@ -277,41 +277,41 @@ func (container *Container) DB() (db *gorm.DB) {

container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))

if err = db.AutoMigrate(&entities.Message{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Message{})))
}

if err = db.AutoMigrate(&entities.MessageThread{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.MessageThread{})))
}

if err = db.AutoMigrate(&entities.User{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.User{})))
}

if err = db.AutoMigrate(&entities.Phone{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Phone{})))
}

if err = db.AutoMigrate(&entities.PhoneNotification{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.PhoneNotification{})))
}

if err = db.AutoMigrate(&entities.BillingUsage{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.BillingUsage{})))
}

if err = db.AutoMigrate(&entities.Webhook{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Webhook{})))
}

if err = db.AutoMigrate(&entities.Discord{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Discord{})))
}

if err = db.AutoMigrate(&entities.Integration3CX{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Integration3CX{})))
}
//if err = db.AutoMigrate(&entities.Message{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Message{})))
//}
//
//if err = db.AutoMigrate(&entities.MessageThread{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.MessageThread{})))
//}
//
//if err = db.AutoMigrate(&entities.User{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.User{})))
//}
//
//if err = db.AutoMigrate(&entities.Phone{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Phone{})))
//}
//
//if err = db.AutoMigrate(&entities.PhoneNotification{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.PhoneNotification{})))
//}
//
//if err = db.AutoMigrate(&entities.BillingUsage{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.BillingUsage{})))
//}
//
//if err = db.AutoMigrate(&entities.Webhook{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Webhook{})))
//}
//
//if err = db.AutoMigrate(&entities.Discord{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Discord{})))
//}
//
//if err = db.AutoMigrate(&entities.Integration3CX{}); err != nil {
// container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Integration3CX{})))
//}

return container.db
}
Expand Down

0 comments on commit 15ac42e

Please sign in to comment.