I am currently writing a migration from Drupal 6 to Drupal 7. I am using the Migrate module (2.7), Drupal-to-Drupal migration module (2.1) and migrate extras (2.5). I have been successful in migrating images, files, boolean, text, and list fields but have hit a brick wall with location fields.

I have tried mapping the source location cck field directly to the Drupal 7 location cck field. This migration runs with no errors but doesn't actually migrate any data.


I have also tried mapping the sub-fields of the location field using the below link as reference: https://www.drupal.org/node/2018113

//Mapping location field
    $this->addFieldMapping('field_location:name', 'name');
    $this->addFieldMapping('field_location:street', 'street');
    $this->addFieldMapping('field_location:additional', 'additional');
    $this->addFieldMapping('field_location:city', 'city');
    $this->addFieldMapping('field_location:province', 'province');
    $this->addFieldMapping('field_location:postal_code', 'postal_code');
    $this->addFieldMapping('field_location:country', 'country');
    $this->addFieldMapping('field_location:latitude', 'latitude');
    $this->addFieldMapping('field_location:longitude', 'longitude');
    $this->addFieldMapping('field_location:source', 'source');
    $this->addFieldMapping('field_location:is_primary', 'is_primary');

  protected function query() {
    $query = parent::query();

    // Join location table
    $query->join('location_instance', 'i', 'i.nid = n.nid AND i.vid = n.vid');
    $query->join('location', 'l', 'l.lid = i.lid');
    $query->fields('l', array('name', 'street', 'additional', 'city', 'province', 'postal_code', 'country', 'latitude', 'longitude', 'source', 'is_primary'));

    return $query;

This throws 'SQLSTATE[22003]: Numeric value out of range: 1264' errors

Example error:

    SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 
'is_primary' at row 1: INSERT INTO {location} (name, street, additional, city, province, 
postal_code, country, latitude, longitude, source, is_primary) VALUES 
(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, 
:db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, 
:db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, 
:db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] 
=> Talk at somewhere [:db_insert_placeholder_1] => 1 Some Road [:db_insert_placeholder_2] 
=> [:db_insert_placeholder_3] => Somewhere [:db_insert_placeholder_4] => 
[:db_insert_placeholder_5] => XXX XXX [:db_insert_placeholder_6] => uk 
[:db_insert_placeholder_7] => 53.321524 [:db_insert_placeholder_8] => -1.509733 
[:db_insert_placeholder_9] => 3 [:db_insert_placeholder_10] => 448 ) 

Which seems to be adding a value of 448 to the is_primary field. This value increments through the errors thrown.

I have tried setting the is_primary default value to 0 using:

$this->addFieldMapping('field_location:is_primary', 'is_primary')->defaultValue('0');


$this->addFieldMapping('field_location:is_primary', 'is_primary')->defaultValue(0); 

The result of this is the same errors.

I have also tried setting the value using a callback:

$this->addFieldMapping('field_location:is_primary', 'is_primary')
->callbacks(array($this, 'fixIsPrimary'));

protected function fixIsPrimary($is_primary_value) {
        $is_primary_value = 0;
      return $is_primary_value;

With the same results. I have also tried not mapping the field using:

$this->addFieldMapping('field_location:is_primary', 'is_primary')->issueGroup(t('DNM'));

With the same results. I have also tried not mapping the field at all:

//$this->addFieldMapping('field_location:is_primary', 'is_primary');

With little effect.

If anyone with more experience with Drupal migrations could offer an insight into location fields, that would be much appreciated.

Thanks in advance,

Tom Sage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.