/*
Creates the database and user account for moebot, if necessary
*/
Creates the database and user account for moebot, if necessary
/ * Creates the database and user account for moebot if necessary * /
func createMoebotDatabase(rootDb *sql.DB, moeDataPass string) {
	rows := rootDb.QueryRow("SELECT COUNT(*) FROM pg_catalog.pg_user WHERE usename = 'moebot'")
	var rowCount int
	rows.Scan(&rowCount)
	if rowCount == 0 {
		_, err := rootDb.Exec("CREATE USER moebot WITH PASSWORD '" + moeDataPass + "'")
		if err != nil {
			log.Fatal("Unable to create user moebot - ", err)
		}
	}
	rows = rootDb.QueryRow("SELECT COUNT(*) FROM pg_database WHERE datname = 'moebot'")
	rows.Scan(&rowCount)
	if rowCount == 0 {
		_, err := rootDb.Exec("CREATE DATABASE moebot OWNER moebot")
		if err != nil {
			log.Fatal("Unable to create database for moebot - ", err)
		}
	}
}
func createMoebotDatabase ( rootDb * sql . DB , moeDataPass string ) { rows := rootDb . QueryRow ( " " ) var rowCount int rows . Scan ( & rowCount ) if rowCount == 0 { _ , err := rootDb . Exec ( " " + moeDataPass + " " ) if err != nil { log . Fatal ( " " , err ) } } rows = rootDb . QueryRow ( " " ) rows . Scan ( & rowCount ) if rowCount == 0 { _ , err := rootDb . Exec ( " " ) if err != nil { log . Fatal ( " " , err ) } } }
Creates the database and user account for moebot, if necessary
Creates the database and user account for moebot if necessary
// create moebot user + database // for some reason this only works when it's non-parameterized...