I am using mongodb as the backend for the node_save functionality and I have migrated my custom fields. So for every node save it calls the hook_field_storage_write()
. Thus the data is saved in the mysql and then calls the mongodb implementation. This hook inserts the document in mongodb and calls the mongodb_migrate_write_helper
. In the function the migrated fields are set with the value of deleted column as 2.
Thus if I have migrated a field 'field_email' from mysql to mongodb the mongodb_migrate_write_helper sets the field_email for the entity as deleted = 2. What does the deleted flag do? Are the rows marked as deleted = 2 deleted in a specific point of time or by some hook calls? . I have seen in many instances in the core modules where deleted is set as 1. Are there any purge scripts that are run at specific points of time for deletion of fields marked as deleted.
function mongodb_migrate_write_helper($entity_type, $entity_id) {
$migrate_fields = variable_get('mongodb_migrate_fields', array()); // Migrated field names are stored in variable.
foreach ($migrate_fields as $field_name => $v) {
$field = field_info_field($field_name);
db_update(_field_sql_storage_tablename($field))
->fields(array('deleted' => 2))
->condition('entity_type', $entity_type)
->condition('entity_id', $entity_id)
->execute();
}
}