function drush_sql_register_post_sync_op

8.0.x drush_sql_register_post_sync_op($id, $message, $query = NULL)
6.x drush_sql_register_post_sync_op($id, $message, $query = NULL)
7.x drush_sql_register_post_sync_op($id, $message, $query = NULL)
4.x drush_sql_register_post_sync_op($id, $message, $query = NULL)
5.x drush_sql_register_post_sync_op($id, $message, $query = NULL)
master drush_sql_register_post_sync_op($id, $message, $query = NULL)

Call from a pre-sql-sync hook to register an sql query to be executed in the post-sql-sync hook.


$id: String containing an identifier representing this operation. This id is not actually used at the moment, it is just used to fufill the contract of drush contexts.

$message: String with the confirmation message that describes to the user what the post-sync operation is going to do. This confirmation message is printed out just before the user is asked whether or not the sql-sync operation should be continued.

$query: String containing the sql query to execute. If no query is provided, then the confirmation message will be displayed to the user, but no action will be taken in the post-sync hook. This is useful for drush modules that wish to provide their own post-sync hooks to fix up the target database in other ways (e.g. through Drupal APIs).

See also

drush_sql_pre_sql_sync() and @see drush_sql_post_sql_sync().

2 calls to drush_sql_register_post_sync_op()
hook_drush_sql_sync_sanitize in docs/drush.api.php
Sql-sync sanitization example. This is equivalent to the built-in --sanitize option of sql-sync, but simplified to only work with default values on Drupal 6 + mysql.
sql_drush_sql_sync_sanitize in commands/sql/
Sql sync sanitization function. This hook function will sanitize usernames and passwords in the user table when the --sanitize option is used. It is also an example of how to write a database sanitizer for sql sync.


commands/sql/, line 879
Drush sql commands


function drush_sql_register_post_sync_op($id, $message, $query = NULL) {
  $options = drush_get_context('post-sync-ops');

  $options[$id] = array(
    'message' => $message,
    'query' => $query,

  drush_set_context('post-sync-ops', $options);