// Check execute queries in the database
// The first is a simple one used to verify if the database is up
// If is Up then another query is executed, querying for the database version
Check execute queries in the database
The first is a simple one used to verify if the database is up
If is Up then another query is executed, querying for the database version
// Check execute queries in the database // The first is a simple one used to verify if the database is up // If is Up then another query is executed querying for the database version
func (c Checker) Check() health.Health {
	var (
		version string
	)
	h := health.NewHealth()
	if c.DB == nil {
		h.Down().AddInfo("error", "Empty resource")
		return h
	}
	tx := c.DB.Raw(`Select version()`).Scan(&version)
	if tx.Error != nil || version == "" {
		h.Down().AddInfo("error", tx.Error.Error())
		return h
	}
	h.Up().AddInfo("version", version)
	return h
}
func ( c Checker ) Check ( ) health . Health { var ( version string ) h := health . NewHealth ( ) if c . DB == nil { h . Down ( ) . AddInfo ( " " , " " ) return h } tx := c . DB . Raw ( `Select version()` ) . Scan ( & version ) if tx . Error != nil || version == " " { h . Down ( ) . AddInfo ( " " , tx . Error . Error ( ) ) return h } h . Up ( ) . AddInfo ( " " , version ) return h }
Check execute queries in the database
The first is a simple one used to verify if the database is up
If is Up then another query is executed, querying for the database version
Check execute queries in the database The first is a simple one used to verify if the database is up If is Up then another query is executed querying for the database version