Exemple #1
0
func setupDatabase(driver string, db *gorm.DB) *gorm.DB {
	if config.Debug {
		db.LogMode(true)
		db.SetLogger(gormrus.New())
	}

	if err := prepareDatabase(driver, db); err != nil {
		logrus.Fatalln(err)
	}

	if err := pingDatabase(driver, db); err != nil {
		logrus.Fatalln(err)
	}

	if err := migrateDatabase(driver, db); err != nil {
		logrus.Fatalln(err)
	}

	return db
}