1

I'm trying to migrate user's content profiles (Drupal 6) to Profile2's profiles (Drupal 7) using the example from http://grasmash.com/article/migrate-classes-content-profile-profile2. When I try importing, I get the following error:

Migration failed with source plugin exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ctp.field_titul_pred_jmenem' in 'field list'

This is the migration class.

class SkipProfile2Migration extends Migration {
  public function __construct() {
    parent::__construct();
    $this->description = t('Migration of content profile into profile2 entities');

    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'nid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'description' => 'D6 Unique Node ID',
          'alias' => 'n',
        )
      ),
      MigrateDestinationNode::getKeySchema(),
        'default'
    );
    $query = Database::getConnection('default', 'legacy')
      ->select('node', 'n')
      ->fields('n', array('nid', 'vid', 'type', 'language', 'title', 'uid', 'status', 'created', 'changed', 'comment', 'promote', 'moderate', 'sticky', 'tnid', 'translate'))
      ->condition('n.type', 'profile', '=');
    $query->join('skip' . '.node_revisions', 'nr', 'n.vid = nr.vid');
    $query->addField('nr', 'body');
    $query->addField('nr', 'teaser');
    $query->addField('nr', 'format');
    $query->join('skip' . '.users', 'u', 'n.uid = u.uid');
    $query->addField('u', 'name');
    $query->leftJoin('skip' . '.content_type_clovek', 'ctp', 'n.nid = ctp.nid AND n.vid = ctp.vid');
    $query->addField('ctp','field_titul_pred_jmenem');
    $query->addField('ctp','field_krestni_jmeno');
    $query->addField('ctp','field_prijmeni');
    $query->addField('ctp','field_titul_za_jmenem');
    $query->addField('ctp','field_telefon');
    $query->addField('ctp','field_email_source');
    $query->addField('ctp','field_ulice');
    $query->addField('ctp','field_cislo_popisne');
    $query->addField('ctp','field_sidlo');
    $query->addField('ctp','field_smerovaci_cislo');
    $query->addField('ctp','field_funkce_cloveka');
    $query->addField('ctp','field_pracoviste');
    $query->addField('ctp','field_stat_iso');
    $query->orderBy('n.nid', 'ASC');

    $source_fields = array(
      'nid' => t('The node ID of the page'),
      'uid' => t('The user ID of a user'),
      'lid' => t('The location ID of a location instance'),
    );

    // Create a MigrateSource object, which manages retrieving the input data.
    $this->source = new MigrateSourceSQL($query, $source_fields);
    $this->destination = new MigrateDestinationProfile2('clovek');

// FIELD MAPPINGS    ...

Can anybody help me, please?

2
  • 1
    Looks like there's no column called field_titul_pred_jmenem in the content_type_clovek table. Wouldn't it be something like field_titul_pred_jmenem_value instead?
    – Clive
    Nov 9, 2012 at 16:16
  • As side note, there isn't the need to write 'skip' . '.users'; just write 'skip.users'. (There is no need to concatenate two literal strings.)
    – apaderno
    Nov 10, 2012 at 20:33

1 Answer 1

1

On Drupal 6 running CCK, the database field names are different from the CCK field names.

In my test site running Drupal 6, I created the following CCK fields:

  • field_code_page (text)
  • field_co_author (user reference)
  • field_book_list (node reference)

    screenshot

The database table created from CCK for the content type containing those fields has the following database fields:

  • field_code_page_value
  • field_co_author_uid
  • field_book_list_nid

    screenshot

It is rather probable the database field is named ctp.field_titul_pred_jmenem_value. To be sure, you should check the database table, as the database field could have a different name, basing on the type of the CCK field.

4
  • Thanks, migration ended up "successfully", but no items were processed. The interesting thing is, that "content_type_clovek" database table didn't have fields like "field_titul_pred_jmenem_value", so I had to create them manually. I have no idea where to proceed from here... Nov 11, 2012 at 0:48
  • If that database field was not present, you should not have used $query->addField('ctp','field_titul_pred_jmenem') in the migration SQL query. Probably, there aren't nodes of that content type with a value for that CCK field.
    – apaderno
    Nov 11, 2012 at 0:52
  • There are nodes with a value for that CCK field, so there must be another reason. So it seems, that my database is different from grasmash.com/article/migrate-classes-content-profile-profile2, where I borrowed the code. Strange. Nov 12, 2012 at 0:06
  • I discovered, that I had a problem in original code, so when I corrected it to ->condition('n.type', 'profile', '=');, it imported everything quite nicely. The problem is, that fields from content profile aren't mapped, so it's rather useless discovery (and yes, I also corrected my field mappings and checked them through Migrate UI). How can I debug this further? Nov 12, 2012 at 0:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.