code: func UpdateGateway(db sqlx.Execer, gw *Gateway) error {
  	now := time.Now()
  	gw.UpdatedAt = now
  
  	res, err := db.Exec(`
  		update gateway set
  			updated_at = $2,
  			first_seen_at = $3,
  			last_seen_at = $4,
  			location = $5,
  			altitude = $6,
  			gateway_profile_id = $7
  		where gateway_id = $1`,
  		gw.GatewayID[:],
  		gw.UpdatedAt,
  		gw.FirstSeenAt,
  		gw.LastSeenAt,
  		gw.Location,
  		gw.Altitude,
  		gw.GatewayProfileID,
  	)
  	if err != nil {
  		return handlePSQLError(err, "update error")
  	}
  	ra, err := res.RowsAffected()
  	if err != nil {
  		return errors.Wrap(err, "get rows affected error")
  	}
  	if ra == 0 {
  		return ErrDoesNotExist
  	}
  
  	_, err = db.Exec(`
  		delete from gateway_board where gateway_id = $1`,
  		gw.GatewayID,
  	)
  	if err != nil {
  		return handlePSQLError(err, "delete error")
  	}
  
  	for i, board := range gw.Boards {
  		_, err := db.Exec(`
  			insert into gateway_board (
  				id,
  				gateway_id,
  				fpga_id,
  				fine_timestamp_key
  			) values ($1, $2, $3, $4)`,
  			i,
  			gw.GatewayID,
  			board.FPGAID,
  			board.FineTimestampKey,
  		)
  		if err != nil {
  			return handlePSQLError(err, "insert error")
  		}
  	}
  
  	log.WithField("gateway_id", gw.GatewayID).Info("gateway updated")
  	return nil
  }
docs: // UpdateGateway updates the given gateway.