func executeSQLFile(filename string, args ...string) fn {
	return func(db *sql.Tx) error {
		data, err := Asset(filename)
		if err != nil {
			return errs.WithStack(err)
		}

		if len(args) > 0 {
			tmpl, err := template.New("sql").Parse(string(data))
			if err != nil {
				return errs.WithStack(err)
			}
			var sqlScript bytes.Buffer
			writer := bufio.NewWriter(&sqlScript)
			err = tmpl.Execute(writer, args)
			if err != nil {
				return errs.WithStack(err)
			}
			// We need to flush the content of the writer
			writer.Flush()
			_, err = db.Exec(sqlScript.String())
		} else {
			_, err = db.Exec(string(data))
		}

		return errs.WithStack(err)
	}
}
// executeSQLFile loads the given filename from the packaged SQL files and
// executes it on the given database. Golang text/template module is used
// to handle all the optional arguments passed to the sql files
executeSQLFile loads the given filename from the packaged SQL files and
executes it on the given database. Golang text/template module is used
to handle all the optional arguments passed to the sql files
// executeSQLFile loads the given filename from the packaged SQL files and // executes it on the given database . Golang text / template module is used // to handle all the optional arguments passed to the sql files
func executeSQLFile(filename string, args ...string) fn {
	return func(db *sql.Tx) error {
		data, err := Asset(filename)
		if err != nil {
			return errs.WithStack(err)
		}
		if len(args) > 0 {
			tmpl, err := template.New("sql").Parse(string(data))
			if err != nil {
				return errs.WithStack(err)
			}
			var sqlScript bytes.Buffer
			writer := bufio.NewWriter(&sqlScript)
			err = tmpl.Execute(writer, args)
			if err != nil {
				return errs.WithStack(err)
			}
			writer.Flush()
			_, err = db.Exec(sqlScript.String())
		} else {
			_, err = db.Exec(string(data))
		}
		return errs.WithStack(err)
	}
}
func executeSQLFile ( filename string , args ... string ) fn { return func ( db * sql . Tx ) error { data , err := Asset ( filename ) if err != nil { return errs . WithStack ( err ) } if len ( args ) > 0 { tmpl , err := template . New ( " " ) . Parse ( string ( data ) ) if err != nil { return errs . WithStack ( err ) } var sqlScript bytes . Buffer writer := bufio . NewWriter ( & sqlScript ) err = tmpl . Execute ( writer , args ) if err != nil { return errs . WithStack ( err ) } writer . Flush ( ) _ , err = db . Exec ( sqlScript . String ( ) ) } else { _ , err = db . Exec ( string ( data ) ) } return errs . WithStack ( err ) } }
executeSQLFile loads the given filename from the packaged SQL files and
executes it on the given database.
executeSQLFile loads the given filename from the packaged SQL files and executes it on the given database .
// We need to flush the content of the writer