Created
July 31, 2014 14:46
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* 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