Civi is using it's own (not shared with Drupal) database. During a script to rebuild a dev/test site from production data I want to drop all the tables in the civi dev db. How do I do that?
After painstakingly trying civitables=$(drush civicrm-sql-query "show tables" | tr '\n' ',' | sed 's/,$//') && drush civicrm-sql-query "drop table $civitables"
I realized I could more simply do drush civicrm-sql-query "drop table like 'civi%'"
but both of these are giving me "Query failed" error. Why would these queries fail or what could I inspect to see why the failed? How can all the tables be dropped using drush
?
*edits...
The drop table like...
is apparently invalid sql sytax. Doh.
And the civitables=$(drush civicrm-sql-query "show tables" | tr '\n' ',' | sed 's/,$//') && drush civicrm-sql-query "drop table $civitables"
appears to fail due to Cannot delete or update a parent row: a foreign key constraint fails
which apparently needs SET FOREIGN_KEY_CHECKS=0;
in order to work but when I do that the query passes (doesn't produce error) but fails to delete any tables.
drush sql-drop
and that's what I want for civicrm!