Skip to content

Instantly share code, notes, and snippets.

@pebosi
Created July 31, 2014 14:46
Show Gist options
  • Save pebosi/f3cecd200eddf8468009 to your computer and use it in GitHub Desktop.
Save pebosi/f3cecd200eddf8468009 to your computer and use it in GitHub Desktop.
Drupal: Reset field_config type and module to field_set_storage after using mongo_db_migrate
/**
*
* When trying mongo_field_storage, and want to go back to old settings use this:
*
**/
function custom_field_config() {
$res = db_query("SELECT * FROM {field_config}");
$data = $res->fetchAll();
foreach ($data as $key => $val) {
$config = unserialize($val->data);
if ($config['storage_type'] != 'field_sql_storage') {
$config['storage']['type'] = 'field_sql_storage';
$config['storage_type'] = 'field_sql_storage';
$config['storage']['module'] = 'field_sql_storage';
$config['storage_module'] = 'field_sql_storage';
unset($config['storage']['mongodb_migrate']);
$config_new = serialize($config);
db_update('field_config')->fields(array(
'data' => $config_new,
))
->condition('id', $val->id)
->execute();
}
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment