Migrate: What's the difference between prepare() and prepareRow()? Using the Migrate module: I understand that prepareRow() runs a filter on the row and should return TRUE or FALSE based on some conditions, which allows a row to be migrated or not, but could someone clarify:


when to use prepare()
when to use prepareRow()
why you wouldn't add a filter in the initial sql query to filter row results that you might remove/include in either of the above


Thanks!
This is all covered in-depth in the Migrations classes documentation provided by the project. Specifically in the Commononly Implemented Migration methods page which says the following and includes further simple example function implementations. From the docs ...

function prepare_row($row)


  The prepareRow() method is called by the source class next() method,
  after loading the data row. The argument $row is a stdClass object
  containing the raw data as provided by the source. There are two
  primary reasons to implement prepareRow():
  
  
  To modify the data row before it passes through any further methods
  and handlers: for example, fetching related data, splitting out source
  fields, combining or creating new source fields based on some logic.
  To conditionally skip a row (by returning FALSE).
  


function prepare($entity, stdClass $row)


  The Migration class prepare() method is called by the destination
  class prepare() method, after it has called all field-level prepare()
  methods and immediately before the destination object is saved. The
  $entity argument is the destination object as populated by the initial
  field mappings and manipulated by the field-level methods; the $row
  argument is an object containing the data after prepareRow() and any
  callbacks have been applied. The prepare() method is the last chance
  to manipulate the destination object before it is saved to the Drupal
  database. It is important to remember that, since it is called after
  the field handlers, fields will be in their fully-expanded forms
  (i.e., in Drupal 7 a text field value will be at
  $entity-&gt;field_textual_data['und'][0]['value'] rather than simply
  $entity-&gt;field_textual_data).


The Migrate module is a framework which allows you to encapsulate a migration process from a source piece of data to a destination location and configuration. A migration consists of:


define where the data is
define where the data should go
fetch a piece of data (row)
sanitize the data
begin to move the data (say into an Entity)
actually move the data
after moving the data perform additional action(s)


The API provides hooks to affect the data being moved in this life cycle of a migration. By excluding data from the migration via your initial query you're limiting how much control you have over the total data you could move. For sub-migrations you may find this useful. But in a general content migration you would want your migration to be as all-encompassing as possible.