function content_migrate_rollback in Content Construction Kit (CCK) 7.3
Helper function to perform rollback.
3 calls to content_migrate_rollback()
- content_migrate_rollback_submit in modules/
content_migrate/ includes/ content_migrate.admin.inc - Submit handler.
- drush_content_migrate_rollback in modules/
content_migrate/ includes/ content_migrate.drush.inc - Command callback.
- _content_migrate_batch_process_migrate_data in modules/
content_migrate/ includes/ content_migrate.admin.inc - Batch operation callback to migrate data. Copy old table data to new field table.
File
- modules/
content_migrate/ includes/ content_migrate.admin.inc, line 165 - content_migrate.admin.inc Code to process field data migration, moved into a separate file for efficiency.
Code
function content_migrate_rollback($field_names) {
foreach ($field_names as $field_name) {
$field = field_info_field($field_name);
// Deleting the field only marks it for deletion.
field_delete_field($field_name);
// We are bypassing the field batch processing
// and simply deleting all the data.
// The assumption is that the migration was
// unsuccessful and will be re-attempted
// and we need to remove all traces of the
// new field for later migrations to work.
$new_table = content_migrate_new_table($field);
db_drop_table($new_table);
$instances = field_read_instances(array(
'field_id' => $field['id'],
), array(
'include_deleted' => 1,
));
foreach ($instances as $instance) {
field_purge_instance($instance);
}
field_purge_field($field);
drupal_set_message(t('Rolling back @field_name.', array(
'@field_name' => $field_name,
)));
}
}