You are here

function migrate_update_6012 in Migrate 6

File

./migrate.install, line 483
Implementation of profile destination handling

Code

function migrate_update_6012() {
  $ret = array();

  // Flag indicates the primary key of the destination
  db_add_field($ret, 'migrate_content_mappings', 'primary_key', array(
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));

  // Set the flag for known destination PKs
  $sql = "SELECT mcsid, contenttype\n          FROM {migrate_content_sets}\n          WHERE contenttype IN ('node', 'user', 'comment', 'role', 'term')";
  $result = db_query($sql);
  while ($row = db_fetch_object($result)) {
    $sql = "UPDATE {migrate_content_mappings}\n            SET primary_key=1\n            WHERE mcsid=%d AND destfield='%s'";
    switch ($row->contenttype) {
      case 'node':
        $destfield = 'nid';
        break;
      case 'user':
        $destfield = 'uid';
        break;
      case 'comment':
        $destfield = 'cid';
        break;
      case 'role':
        $destfield = 'rid';
        break;
      case 'term':
        $destfield = 'tid';
        break;
      default:
        $destfield = '';
        break;
    }
    if ($destfield) {
      db_query($sql, $row->mcsid, $destfield);
    }
  }
  return $ret;
}