Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for dropping the CiviCRM database with drush. #407

Open
wants to merge 1 commit into
base: 7.x-master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions drush/civicrm.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ function civicrm_drush_command() {
'file' => 'Path to a file containing the SQL to be run. ',
),
);
$items['civicrm-sql-drop'] = array(
// explicit callback declaration and non-standard name to avoid collision with "sql-query"
'callback' => 'drush_civicrm_sqldrop',
'description' => 'Drop all tables in the CiviCRM database.',
'options' => array(
'yes' => 'Skip confirmation and proceed.',
),
);
$items['civicrm-sql-cli'] = array(
// explicit callback declaration and non-standard name to avoid collision with "sql-cli"
'callback' => 'drush_civicrm_sqlcli',
Expand Down Expand Up @@ -1358,6 +1366,52 @@ function drush_civicrm_post_civicrm_sqlquery() {
_civicrm_dsn_close();
}

/**
* Implements drush_hook_pre_COMMAND().
*
* this function is called when using drush 6.
*/
function drush_civicrm_pre_civicrm_sql_drop() {
_civicrm_dsn_init();
}

/**
* Implements drush_hook_pre_COMMAND().
*
* this function is called when using drush 5.
*/
function drush_civicrm_pre_civicrm_sqldrop() {
_civicrm_dsn_init();
}

/**
* Implementation of command 'civicrm-sql-drop'
*/
function drush_civicrm_sqldrop() {
drush_sql_query("SET GLOBAL foreign_key_checks = 0;");
$output = drush_sql_drop();
drush_sql_query("SET GLOBAL foreign_key_checks = 1;");
return $output;
}

/**
* Implements drush_hook_post_COMMAND().
*
* this function is called when using drush 6.
*/
function drush_civicrm_post_civicrm_sql_drop() {
_civicrm_dsn_close();
}

/**
* Implements drush_hook_post_COMMAND().
*
* this function is called when using drush 5.
*/
function drush_civicrm_post_civicrm_sqldrop() {
_civicrm_dsn_close();
}

/**
* Implements drush_hook_pre_COMMAND().
*
Expand Down