lxd/db/schema/query.go
func execFromFile(tx *sql.Tx, path string, hook Hook) error {
	if !shared.PathExists(path) {
		return nil
	}

	bytes, err := ioutil.ReadFile(path)
	if err != nil {
		return errors.Wrap(err, "failed to read file")
	}

	if hook != nil {
		err := hook(-1, tx)
		if err != nil {
			return errors.Wrap(err, "failed to execute hook")
		}
	}

	_, err = tx.Exec(string(bytes))
	if err != nil {
		return err
	}

	err = os.Remove(path)
	if err != nil {
		return errors.Wrap(err, "failed to remove file")
	}

	return nil
}
func execFromFile(tx *sql.Tx, path string, hook Hook) error {
	if !shared.PathExists(path) {
		return nil
	}

	bytes, err := ioutil.ReadFile(path)
	if err != nil {
		return errors.Wrap(err, "failed to read file")
	}

	if hook != nil {
		err := hook(-1, tx)
		if err != nil {
			return errors.Wrap(err, "failed to execute hook")
		}
	}

	_, err = tx.Exec(string(bytes))
	if err != nil {
		return err
	}

	err = os.Remove(path)
	if err != nil {
		return errors.Wrap(err, "failed to remove file")
	}

	return nil
}
// Read the given file (if it exists) and executes all queries it contains.