Community Documentation

Adding serialized data to users data column

Last updated September 10, 2012. Created by kenficara on September 10, 2012.
Log in to edit this page.

The users table has a "data" column which can store serialized data, but you cannot migrate into this field by doing a mapping, because the user migration doesn't provide the "data" field as a possible mapping destination.

Instead, you can add the serialized data in your migration by implementing the prepare() method, which operates on the created entity:

<?php
public function prepare(stdClass $account, stdClass $row) {
 
$account->data = array(
    
'field1' => $row->1,
    
'field2' => $row->2
 
);
}
?>

(This information comes from cameronbprince at this issue. I have confirmed that it works.)

Page status

Needs technical review

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Level
Intermediate
Keywords
migrate, users

Administration & Security Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.