Is it possible to migrate into the statuses field?



mikeryan’s picture

Project: Migrate Extras » Statuses (Social Microblog)
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Miscellaneous » Integrations

Migration support for a contrib module would best go into that module.

IceCreamYou’s picture

Status: Active » Postponed

We're not adding new features in the 1.x branch but will revisit this for 2.x.

I'm not sure it's worthwhile using the Migrate module for Statuses though. The only documentation I see for the Migrate module is the example module included in the package, and it includes queries that explicitly grab data from the old tables. If that's all you're doing, you can just save stuff directly to the {statuses} or {statuses_comments} tables with an INSERT INTO ... SELECT FROM query as most sites won't be doing much else when a status is saved. Anything more complicated than that probably requires custom code for each site in order to match up e.g. recipient IDs, attachments, or whatever.

Elaman’s picture

Issue summary: View changes
Status: Postponed » Needs review
Issue tags: +migrate
4.57 KB

I've been migrating Drupal 6 website to the Drupal 7. Even if this won't be applied to the module, hope this will help someone.

Migration example from Facebook Statuses 6.x-2.x & FB Micropublisher 6.x-1.x:

 * Statuses migration class.
class Statuses6Migration extends Migration {
  public function __construct($arguments) {

    Database::addConnectionInfo($arguments['source_connection'], 'default', $arguments['source_database']);

    $query = Database::getConnection('default', 'legacy')
      ->select('facebook_status', 'fs')
      ->fields('fs', array(
    $query->leftJoin('fbsmp', 'mp', 'mp.sid = fs.sid');
    $query->fields('mp', array('type', 'data'));

    // Don't be scared, this line fetches File ID serialised into the data column, so we map that fid below
    $query->addExpression("IF(mp.type = 'photo', TRIM(BOTH '\"' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(,';',2),':',-1)), NULL)", 'fid');

    $this->source = new MigrateSourceSQL($query);

    $this->destination = new MigrateDestinationStatuses();

    $this->map = new MigrateSQLMap(
        'sid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'alias' => 'fs',
          'description' => 'Status ID'

    $this->addFieldMapping('sender', 'uid')->sourceMigration('Users');
    $this->addFieldMapping('recipient', 'pid')->sourceMigration('Users');
    $this->addFieldMapping('created', 'status_time');
    $this->addFieldMapping('message', 'status');
    $this->addFieldMapping('mp_type', 'type');
    $this->addFieldMapping('mp_data', 'data');
    $this->addFieldMapping('mp_fid', 'fid')->sourceMigration(array('Files'));