db.drush.inc

Mysql provisioning module.

The goal of this module is to create mysql databases and user accounts, for sites that are about to be created. It uses the provision API to tie into the right places in the site creation work flow.

Functions

Namesort descending Description
db_drush_exit Implements hook_drush_exit().
db_drush_help Implements hook_drush_help().
db_drush_init Implements hook_drush_init().
db_provision_register_autoload Register our directory as a place to find provision classes.
db_provision_services Implements hook_provision_services().

Constants

Namesort descending Description
PROVISION_QUERY_REGEXP Indicates the place holders that should be replaced in _db_query_callback().

File

db/db.drush.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Mysql provisioning module.
  5. *
  6. * The goal of this module is to create mysql databases and user accounts, for sites that are about to be created.
  7. * It uses the provision API to tie into the right places in the site creation work flow.
  8. */
  9. //include_once(dirname(__FILE__) . '/../provision.service.inc');
  10. /**
  11. * Implements hook_provision_services().
  12. */
  13. function db_provision_services() {
  14. db_provision_register_autoload();
  15. return array('db' => NULL);
  16. }
  17. /**
  18. * Implements hook_drush_exit().
  19. */
  20. function db_drush_exit() {
  21. // determine how to close it too.
  22. d()->service('db')->close();
  23. }
  24. /**
  25. * Implements hook_drush_help().
  26. */
  27. function db_drush_help($section) {
  28. switch ($section) {
  29. case 'error:PROVISION_CONNECT_DB_FAILED' :
  30. return dt('Unable to connect to database server.');
  31. case 'error:PROVISION_CREATE_DB_FAILED' :
  32. return dt('Unable to create new databases.');
  33. case 'error:PROVISION_GRANT_DB_USER_FAILED' :
  34. return dt('Unable to grant privileges to database users.');
  35. case 'error:PROVISION_DROP_DB_FAILED' :
  36. return dt('Unable to drop database.');
  37. }
  38. }
  39. /**
  40. * Implements hook_drush_init().
  41. */
  42. function db_drush_init() {
  43. db_provision_register_autoload();
  44. }
  45. /**
  46. * Register our directory as a place to find provision classes.
  47. */
  48. function db_provision_register_autoload() {
  49. static $loaded = FALSE;
  50. if (!$loaded) {
  51. $loaded = TRUE;
  52. provision_autoload_register_prefix('Provision_', dirname(__FILE__));
  53. }
  54. }
  55. /**
  56. * Indicates the place holders that should be replaced in _db_query_callback().
  57. */
  58. define('PROVISION_QUERY_REGEXP', '/(%d|%s|%%|%f|%b)/');