Hi

i would to use this module and i try with users..actually i made my custom module and get example from http://btmash.com/article/2011-03-02/migrating-content-part-1-users

but in my case i would to migrate content between 2 differents DB.So i modify settings.php to add the second DB like this (local) :

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'drupal7_cg',
  'username' => 'root',
  'password' => 'root',
  'host' => 'localhost',
  'prefix' => 'd7cg_',
);
$databases['source_cg']['default'] = array(
  'driver' => 'mysql',
  'database' => 'drupal6_cg',
  'username' => 'root',
  'password' => 'root',
  'host' => 'localhost',
  'prefix' => 'd6cg_',
);

then i do a drush ms and get :

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd7cg_drupal7_cg.users' doesn't exist                                          [error]

 Group: default  Total  Importé  Unimported  Statut  Last imported
 GrawitzUser     N/A    0        0           Idle

So i don't understand why this table doesn't already exist in D7,and i would to know if my modifications are good in my .inc file :

/*Definition de la cible et de la source*/
    $query = Database::getConnection('default', 'source_cg')
           ->select('source_table', 'st');


$this->map = new MigrateSQLMap($this->machineName,
    array(
    'uid' => array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'description' => 'D6 Unique User ID',
    'alias' => 'u',
    )
    ),
    MigrateDestinationUser::getKeySchema(),
            'source_cg'
    );

thanks

Comments

aiphes’s picture

Modifiying settings.php like this :

 $databases['db_source']['default'] = array(
   'driver' => 'mysql',
   'database' => 'drupal6_er',
   'username' => 'root',
   'password' => 'root',
   'host' => 'localhost',
   'prefix' => 'd6er_',
 );
 $databases['db_destination']['default'] = array(
   'driver' => 'mysql',
   'database' => 'drupal7_er',
   'username' => 'root',
   'password' => 'root',
   'host' => 'localhost',
   'prefix' => 'd7er_',
 );
 $databases['default'] = $databases['db_destination'];

how to define source / target db in my migrate class ?

but i think i've an issue in definition of source/target db as in migrate ui i get :
18 fields mapped as destination and 10 as source, and it's not reality,actually ma D6 db get 20 fields and my D7 db get 17 fields in users table ..what do you think about ?

this is my mapping code :


$this->addFieldMapping('name', 'name')->dedupe('users', 'name');
    $this->addFieldMapping('pass', 'pass');
    $this->addFieldMapping('mail', 'mail')->dedupe('users', 'mail');
    $this->addFieldMapping('language')->defaultValue('');
    $this->addFieldMapping('theme')->defaultValue('');
    $this->addFieldMapping('signature')->defaultValue('');
    $this->addFieldMapping('signature_format')->defaultValue('filtered_html');
    $this->addFieldMapping('created', 'created');
    $this->addFieldMapping('access', 'access');
    $this->addFieldMapping('login', 'login');
    $this->addFieldMapping('status', 'status');
    $this->addFieldMapping('picture')->defaultValue(0);
    $this->addFieldMapping('init', 'init');
    $this->addFieldMapping('timezone')->defaultValue(NULL);
    $this->addFieldMapping('path')->issueGroup(t('DNM'));
    $this->addFieldMapping('roles', 'roles');
    $this->addFieldMapping('is_new')->defaultValue(TRUE);
    $this->addFieldMapping('uid', 'uid');
aiphes’s picture

ok figure out connexion issue with:

$query = Database::getConnection('db_destination', 'db_source')
    ->select('users', 'u')
...

in this case i need to import user_role table data too..can i do that in the same migration class ?

aiphes’s picture

i get these warnings on another migration :

Warning : Illegal offset type in isset or empty dans SelectQuery->addField() (ligne 1279 dans /var/www/drupal7/includes/database/select.inc).
Warning : Illegal offset type in isset or empty dans SelectQuery->addField() (ligne 1286 dans /var/www/drupal7/includes/database/select.inc).
Warning : Illegal offset type dans SelectQuery->addField() (ligne 1291 dans /var/www/drupal7/includes/database/select.inc).
mikeryan’s picture

Title: Migrate D6 to D7 between differents DB » Migrate D6 to D7 using prefixes
Status: Active » Postponed (maintainer needs more info)

Have you looked at the Drupal-to-Drupal data migration module, which does a lot of the work for you (including mapping user roles)?

Regarding those "illegal offset type" errors, it looks like a problem in building your source query - what does it look like?

aiphes’s picture

Status: Postponed (maintainer needs more info) » Active

yes i know about D2D module but finding less doc about it except on acquia..do you think it's more adapted in my case ?

my problem is to find out source elements to use in my query...here i want to migrate a custom CCK filefield like this :

//Ajout des champs CCK custom par récupération depuis la source (tableSource,alias,..)
    $query->leftJoin('content_field_fichier_joint_lycee','ffjl','n.vid = vid');
    $query->addField('ffjl','field_fichier_joint_lycee_data');

but i don't know the alias (?) value, and the 3rd argument for n.vid ...where can i find them ?

aiphes’s picture

Title: Migrate D6 to D7 using prefixes » Migrate D6 to D7 between 2 differents DB

Thanks for tips on d2d, it's very more simple than original way..i get imported roles,users but users are role unassigned..then i'll do a test with nodes and CCK fields...

aiphes’s picture

so i get many warnings after trying to map custom fields...on migrate UI i get the unmapped field list like this :

field_fichier_joint_lycee	Joindre un fichier
field_fichier_joint_lycee:list	Joindre un fichier subfield
field_fichier_joint_lycee:data	Joindre un fichier subfield

so i do in my nodes.inc d2d file :


$this->sourceFields['field_fichier_joint_lycee'] = t('Fichier joint page lycée');
$this->addFieldMapping('field_fichier_joint_lycee', 'field_fichier_joint_lycee');

after that the line become red to white :) but all others core fields get warning like :

"title" was used as source field in the "title" mapping but is not in list of source fields
"title" was used as destination field in "title" mapping but is not in list of destination fields
"field_fichier_joint_lycee" was used as destination field in "field_fichier_joint_lycee" mapping but is not in list of destination fields

i don't understand because in the Mapping OK tab i see:
Destination Source Par défaut Description Priorité

title	title			OK
field_fichier_joint_lycee	field_fichier_joint_lycee			OK

and idem for all of others fields...is it ok anyway ?

other question,do i map subfields like field_fichier_joint_lycee:data Joindre un fichier subfield ?

thanks

mikeryan’s picture

Project: Migrate » Drupal-to-Drupal data migration
Version: 7.x-2.5 » 7.x-2.x-dev

If you're now using migrate_d2d, it should be detecting the source fields for you, you shouldn't need to add them to sourceFields[] yourself. It seems like something isn't matching up - what does the arguments array you pass when registering your node migration look like?

The migrate_d2d documentation is at http://drupal.org/node/1813498.

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)
aiphes’s picture

Status: Postponed (maintainer needs more info) » Active

i run into error on mapping fields,specially custom ones :

"pathauto" was used as destination field in "" mapping but is not in list of destination fields
"field_published" was used as source field in the "field_publish_date" mapping but is not in list of source fields
"field_publish_date" was used as destination field in "field_published" mapping but is not in list of destination fields
"field_fichier_joint_lycee" was used as source field in the "field_fichier_joint_lycee" mapping but is not in list of source fields
"field_fichier_joint_lycee" was used as destination field in "field_fichier_joint_lycee" mapping but is not in list of destination fields
"field_fichier_joint_lycee:list" was used as source field in the "field_fichier_joint_lycee:list" mapping but is not in list of source fields
"field_fichier_joint_lycee:list" was used as destination field in "field_fichier_joint_lycee:list" mapping but is not in list of destination fields
"field_fichier_joint_lycee:data" was used as source field in the "field_fichier_joint_lycee:data" mapping but is not in list of source fields
"field_fichier_joint_lycee:data" was used as destination field in "field_fichier_joint_lycee:data" mapping but is not in list of destination fields
"field_lien_page_lycee" was used as source field in the "field_lien_page_lycee" mapping but is not in list of source fields
"field_lien_page_lycee" was used as destination field in "field_lien_page_lycee" mapping but is not in list of destination fields
"field_video_lycee" was used as source field in the "field_video_lycee" mapping but is not in list of source fields
"field_video_lycee" was used as destination field in "field_video_lycee" mapping but is not in list of destination fields

i put this in my module code:

$this->sourceFields['field_page_actus'] = t('Relatif à quel contenu ?');
   $this->sourceFields['field_minipresse'] = t('Illustration du contenu');
   $this->sourceFields['field_fichier_joint'] = t('Joindre un fichier');
   $this->sourceFields['field_slideshare_actu'] = t('Slideshare inclus');
   $this->sourceFields['field_video_externe'] = t('Video incluse');

i need help on taxonomy too, because fields like taxonomy_vocabulary_11 are not mapped..because on D6 i don't use field to select terms.

clear cache,nothing change.why ?

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Again, how are you registering the migration? What exactly does the arguments array look like? Messages like

"field_published" was used as source field in the "field_publish_date" mapping but is not in list of source fields
"field_publish_date" was used as destination field in "field_published" mapping but is not in list of destination fields

suggest that your migration class has a line like

$this->addFieldMapping('field_publish_date', 'field_published');

But that the source_type you used when registering your migration does not contain field_published, and that the destination_type you used on registration does not contain field_publish_date.

aiphes’s picture

Status: Postponed (maintainer needs more info) » Active

for taxonomy i do :

  $this->addFieldMapping('taxonomy_vocabulary_11', '11')
        ->sourceMigration('NomMachineMigrationTerm');

but i don't know what i must type for NomMachineMigrationTerm...in my .module :

$arguments = $common_arguments + array(
    'description' => t('Migration de vocabulaire depuis D6'),
    'machine_name' => 'D2D_ProvenceFormationVoc_11',
    'source_vocabulary' => '11', // vid of the Drupal 6 “Categories” vocabulary
    'destination_vocabulary' => 'Actualité importante',
);
// First argument is the migration class name
Migration::registerMigration('DrupalTerm6MigrationVoc', $arguments['machine_name'],$arguments);

I remove

$this->addFieldMapping('field_publish_date', 'field_published');

because i don't use a date field for this content,only the core "created" value.
Do i map these kind of fields ? :

field_minipresse:file_class
field_minipresse:language
field_minipresse:destination_dir	
field_minipresse:destination_file
field_minipresse:file_replace
field_minipresse:preserve_files
field_minipresse:source_dir
aiphes’s picture

For file sor images, i see i do create a dedicated migration for files, like http://drupal.stackexchange.com/questions/50004/file-or-image-migrate-fr...

so i add this in my .module file :

$file_arguments = $common_arguments + array(
  'description' => t('Migration des fichiers depuis Drupal 6'),
  'machine_name' => 'D2D_ProvenceFormation_Files',
  'source_dir' => '/var/www/drupal6/sites/provence-formation.vmdev/media/',
);

// We just use the migrate_d2d D6 migration class as-is.
Migration::registerMigration('FileMigration', $file_arguments['machine_name'],
$file_arguments);

and create a .inc file to specify a date start for import like for nodes :

class FileMigration extends DrupalFile6Migration { 
protected function query() {
    $query = parent::query();
<del>    $query->condition('created', strtotime('28-03-2013'), '>');</del>
$query->condition('timestamp', strtotime('28-03-2013'), '>');
    return $query;
 }
}

but i get :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created' in 'where clause'                                                               [error]

 Group: default                        Total  Importé  Non importé  Statut      Derniers importés
 D2D_ProvenceFormationMenu             7      0        7            En attente
 D2D_ProvenceFormationNodes_Actu       2      0        2            En attente  2013-04-09 15:56:58
 D2D_ProvenceFormationNodes_Files      785    0        785          En attente
 D2D_ProvenceFormationRoles            8      0        8            En attente
 D2D_ProvenceFormationVoc_1            0      0        0            En attente
 D2D_ProvenceFormation_Files           N/A    0        0            En attente
 D2D_ProvenceFormationUser             7      0        7            En attente
 D2D_ProvenceFormationNodes_PageLycee  2      0        2            En attente

so :
- i need to find the column name of the added file like "created" for nodes => found it
- i need to clear old migrations still in memory after flushing cache and run cron

aiphes’s picture

folder is created but files aren't imported into...my last .inc code:

class FileMigration extends DrupalFile6Migration { 
protected function query() {
    $query = parent::query();
    $query->condition('timestamp', strtotime('28-03-2013'), '>');
    return $query;
 }
 public function __construct(array $arguments) {
    parent::__construct($arguments);
    //Le nom machine de la migration de nodes associée comme dépendances
     // $this->dependencies[] = 'D2D_RostandNodes_PageLycee';
    //On défini la source et la cible depuis les infos de base
      $this->source = new MigrateSourceSQL($this->query(),
      $this->sourceFields,NULL, $this->sourceOptions);
      

    $this->addFieldMapping('uid', 'uid');
    
 }
}

no error message given by system, actually nodes are imported from a setting date, but no files or term associated are prevented.

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Mixing all sorts of random issues into one Drupal issue makes it difficult to respond. Taking just a subset of your questions:

  $this->addFieldMapping('taxonomy_vocabulary_11', '11')
        ->sourceMigration('NomMachineMigrationTerm');

'taxonomy_vocabulary_11' isn't going to work - the first argument to addFieldMapping has to be the name of a field on the destinaton content type. If the term_reference field you've created on the content type to hold terms from the vocabulary with the former vid 11 is 'field_category', then the first parameter to addFieldMapping should be 'field_category'.

The destination_vocabulary value below needs to be the machine name of the vocabulary in Drupal 7, not the display name:

$arguments = $common_arguments + array(
    'description' => t('Migration de vocabulaire depuis D6'),
    'machine_name' => 'D2D_ProvenceFormationVoc_11',
    'source_vocabulary' => '11', // vid of the Drupal 6 “Categories” vocabulary
    'destination_vocabulary' => 'actualite_importante',
);
aiphes’s picture

Status: Postponed (maintainer needs more info) » Active

ok i think i needn't to migrate vocabularies as they are yet in D7 after upgrade.
My actual issue is on the migration of files.Folders created but no files into..

$file_arguments = $common_arguments + array(
  'description' => t('Migration des fichiers depuis Drupal 6'),
  'machine_name' => 'D2D_ProvenceFormation_Files',
  'source_dir' => '/var/www/drupal6/sites/provence-formation.vmdev/media/', //<- path of the source
  'destination_dir' => 'public://', //<- path on destination ,is it right ?
);

// We just use the migrate_d2d D6 migration class as-is.
Migration::registerMigration('FilesMigration', $file_arguments['machine_name'],
$file_arguments);
mikeryan’s picture

Status: Active » Closed (works as designed)

This issue is already overloaded with unrelated questions, please open a separate issue per question.