Skip to content

Instantly share code, notes, and snippets.

@sirkitree
Created November 6, 2012 12:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirkitree/4024377 to your computer and use it in GitHub Desktop.
Save sirkitree/4024377 to your computer and use it in GitHub Desktop.
Don't allow yourself to screw up with sql-sync to the production environment.
<?php
$options['shell-aliases']['syncdb'] = '!drush --verbose --yes sql-sync --create-db @pac12.prod @self';
<?php
/**
* @file
* Policy commandfile.
*
* Validates commands as they are issued and returns an error
* or changes options when policy is violated.
*/
/**
* Implement of drush_hook_COMMAND_validate().
*
* Prevent catastrophic braino when syncing databases.
*/
function drush_policy_sql_sync_validate($source = NULL, $destination = NULL) {
if ($destination == '@pac12.prod') {
return drush_set_error(dt('You may never overwrite the production database.'));
}
}
/**
* Implement of drush_hook_COMMAND_validate().
*
* Prevent catastrophic braino when rsyncing files.
*/
function drush_policy_core_rsync_validate($source = NULL, $destination = NULL) {
if (preg_match('/^@pac12.prod/', $destination)) {
return drush_set_error(dt('You may never overwrite the production files.'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment