diff --git a/mongodb_migrate/README.txt b/mongodb_migrate/README.txt new file mode 100644 index 0000000..7041cc9 --- /dev/null +++ b/mongodb_migrate/README.txt @@ -0,0 +1,23 @@ +MongoDB Migrate +=============== + +Step 1: Add $conf['field_storage_default'] = 'mongodb_field_storage'; to settings.php + +Step 2: Run drush mongodb-migrate-prepare + +Step 3: Run drush mongodb-migrate + + Options include: + + --timeout=" collections exist and have the expected values. + +Step 5: If for some reason you need to re-run the migration, go back to step 2 to reset it and start over. diff --git a/mongodb_migrate/mongodb_migrate.drush.inc b/mongodb_migrate/mongodb_migrate.drush.inc index 29beea7..107cfff 100644 --- a/mongodb_migrate/mongodb_migrate.drush.inc +++ b/mongodb_migrate/mongodb_migrate.drush.inc @@ -3,14 +3,11 @@ function mongodb_migrate_drush_command() { $items['mongodb-migrate-prepare'] = array( 'description' => 'Prepare for migrate. Resets existing migration. No data is lost.', - 'examples' => array( - 'drush mongodb-field-update body', - ), ); $items['mongodb-migrate'] = array( - 'description' => 'Migrates fields. Run mongodb-field-update first.', + 'description' => 'Migrates fields. Run mongodb-migrate-prepare first.', 'options' => array( - 'timeout' => 'How many seconds the command should run. 0 for no timeout. Defaults to 900s.', + 'timeout' => 'How many seconds the command should run. 0 for no timeout. Defaults to 900.', 'count' => 'How many entities should the command process. 0 for all. Defaults to all.', ), ); @@ -25,6 +22,7 @@ function drush_mongodb_migrate_prepare() { $fields = db_query('SELECT field_name FROM {field_config} WHERE storage_type = :storage_type OR data LIKE :mongodb_migrate', array(':storage_type' => 'field_sql_storage', ':mongodb_migrate' => '%mongodb_migrate%'))->fetchCol(); foreach ($fields as $key => $field_name) { $field = field_read_field($field_name); + print_r($field); if (!db_table_exists(_field_sql_storage_tablename($field))) { unset($fields[$key]); continue; @@ -64,6 +62,9 @@ function drush_mongodb_migrate_prepare() { field_cache_clear(); } +/** + * Drush callback; migrate all field data into MongoDB. + */ function drush_mongodb_migrate() { $finish_time = time() + drush_get_option('timeout', 900); $limit = drush_get_option('count', 0); @@ -81,11 +82,8 @@ function drush_mongodb_migrate() { $query = db_select($entity_info['base table'], 'e') ->fields('e', array($id_field)) ->condition($id_field, $max, '>') - ->orderBy($id_field, ASC) + ->orderBy($id_field, 'ASC') ->range(0, 1); - if (isset($entity_info['entity keys']['bundle'])) { - $query->condition($entity_info['entity keys']['bundle'], $bundles); - } $entity_id = $query->execute()->fetchField(); if ($entity_id) { $collection->db->resetError();