code: def compile_migrations(migrator, models, reverse=False):
      
      source = migrator.orm.values()
      if reverse:
          source, models = models, source
  
      migrations = diff_many(models, source, migrator, reverse=reverse)
      if not migrations:
          return False
  
      migrations = NEWLINE + NEWLINE.join('\n\n'.join(migrations).split('\n'))
      return CLEAN_RE.sub('\n', migrations)
docs: Compile migrations for given models.