Problem/Motivation

When synchronizing our production database to another environment, we do not want webform submissions to be carried along with the database dump. We did not want to use https://www.drupal.org/project/webform_sanitize module as we wanted to remove all data about submisisons in our non-live environment rather than sanitize the data in each submission.

Proposed resolution

Support truncating the webform submission tables via drush sql-sanitize hooks/commands

Remaining tasks

* Make the Drush 8 sanitization optional like we did with --sanitize-webform-submissions=no with Drush 9

User Acceptance Test

Drush 9.x+

  • Run drush sql:sanitize confirm that 'Truncate webform submission tables.' operation appears
  • Run drush sql:sanitize --sanitize-email=no --sanitize-password=no;
  • Confirm webform_submission tables have been truncated

Drush 8.x

  • Run drush sql-sanitize confirm that 'Truncate webform submission tables.' operation appears
  • Run drush sql-sanitize --sanitize-email=no --sanitize-password=no;
  • Confirm webform_submission tables have been truncated
  • Run drush sql-sanitize --sanitize-email=no --sanitize-password=no --db-prefix;
  • Confirm webform_submission tables have been truncated

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

@todo

Comments

Dave Reid created an issue. See original summary.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new4.02 KB
dave reid’s picture

Issue summary: View changes
dave reid’s picture

Title: Add support for sanitizing submissions with drush sql-sanitize » Add support for truncating submissions with drush sql-sanitize
Issue summary: View changes
jrockowitz’s picture

Issue summary: View changes
StatusFileSize
new5.83 KB

Thanks for the patch.

For Drush 9.x, everything worked fine.

For Drush 8.x, I had to remove some of the table prefix detection code which was throwing an error. I also looked at the Webform D7 drush command.

I also moved the drush 8 hooks into a dedicated file.

Finally, I also added the webform_submission_log table to list of tables to be truncated.

jrockowitz’s picture

Issue summary: View changes
jrockowitz’s picture

StatusFileSize
new5.81 KB

I ran through the UAT one more time and for Drush 8.x, I had tweak the code to use exactly what was setup in Webform 7.x-4.x to get the truncation to work as expected.

  • jrockowitz authored 0bded4a on 8.x-5.x
    Issue #3081606 by jrockowitz, Dave Reid: Add support for truncating...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.