Drush provides a feature called sql-sanitize that helps to delete data that shouldn't leave a production environment.

I think all entityform submissions should be deleted when drush sql-sanitize runs, similar to what webform is doing.

I will implement this for a project I'm working on, let me know if you would accept a patch that does that.

Comments

Pere Orga created an issue. See original summary.

Pere Orga’s picture

Issue summary: View changes
joelpittet’s picture

Yes that sounds handy

Pere Orga’s picture

Status: Active » Postponed

Unfortunately I haven't found a way that works across all supported database servers (drush_sql_register_post_sync_op expects database queries). The main problem is that I don't think there is a proper way to get all relevant database tables (field and revision tables) of all entityforms. And ideally, data in fields shared by other bundles (non-entityform) should not be wiped out.

I've found drush_shrinkdb doing something similar just for MySQL: http://cgit.drupalcode.org/drush_shrinkdb/tree/src/Query/EntityType.php

At the end I think I'm going to run manually something like this after sql-sanitize: (terribly slow, by the way)

$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'entityform')->execute();
entity_delete_multiple('entityform', array_keys($entities['entityform']));
joelpittet’s picture

Status: Postponed » Active

Seems like you're on the right path. Keeping the status active. Postponed is usually postponed on some other actionable issue so there is a forseeable end.

Pere Orga’s picture

Faster version of the code above, and in a drush command:

drush php-eval "entity_delete_multiple('entityform', db_query('SELECT entityform_id FROM {entityform}')->fetchCol());"

IMHO the best would be to add an option to sanitize data in Drush without using SQL. Perhaps I'll create an issue in Drush's issue queue for that.