Posted 03.09.2011 by Jack
Drush for Teams
- // Write code
- git commit && git push
- //need most recent config?
- drush site-install -y welcom
- install drupal with profile with drush: drush site-install -y (which is the simplified command because of his drushrc.php) full command: drush si --yes $install_profile_name
- Create installation profile files to quickly start from scratch with your standard setup
- drushrc.php can include options you use often for drush commands (e.g. site-install)
- place drushrc.php into root of your Drupal site and commit it
- Pre-live - reinstall.sh (bash script that includes the bash commands your team needs to run before the reinstall, e.g. git pull)
- drush sql-sync @prod @loca --sanitize: does a cache check (can be disabled, but checks for dump within 24 hours and doesn't do anotther one now if it finds one), generates table list, performs sql-dump on source database (@prod), rsync from the source to the target (@local), import now-local sql dump file, runs sanitize options that you've configured. Lots of optimizations for teams, move big databases quickly.
- --sanitize: by default, overwrites account email and password with any heuristic you want; hook_drush_sql_sync_sanitize() for you to write your own routine for what happens during the --sanitize operation
- @prod and @local are site aliases in aliaes.drushrc.php - collection of options that specify which ssh connection to a server to use to get the database. fancy features like site lists and inheritance. Example files comes with lots of documentation.
- drush topic $command (e.g. drush topic docs-aliases) -- documentation for drush commands
- policy.drush.inc (drush topic docs-policy): enforce the rules of the team, e.g. deny sql-sync TO production server, allows updatedb for only some users
- Commands > drush script
- Write commands for your development team so they can easily figure out docs, options, args, examples, topics - structured way of telling people what you've written
- When you write a command it shows up when you run drush help
- Commands can have dependencies listed and enforced, validation and rollback
- drush make-me-a-sandwich
- Adapt to typical things that Linux shell users are accustomed to, packaged utilities for getting common tasks done
- drush @d6 pml --type=module --status=enabled --no-core --pipe > d6en.txt, repeat for @d7 site (@d6 and @d7 are aliases)
- diff -u d6en.txt and d7en.txt -- after running the above, this compares enabled modules on two different sites
- cat 6em.txt d7en.txt | sort | uniq -d : show list of modules, sorted alphabetically, that are present on both sites.
- --pipe is available on many drush commands
- drush @$your_site_alias sql-cli - drop into sql cli for specified site quickly
- drush @$your_site_alias sql-cli < whatever.sql - import specified file into specified site
- When you run PHP scripts via drush (drush scr $script.php) it runs them with the Drupal site fully bootstrapped, as if you're running commands through devel etc
- alternative in Drush 4: native Drush scripts (see documentation for how to write them)
- When you're going for something more advanced/more flexible than drush scripts
- Commands are like Drupal modules running in a different environment, they are written and work very similarly
- Commands let you use/include help/docs, examples, options, arguments
- Currently working in Drush 4.x and 5.x, will be in 4.e
- Local git caching for pm with --cache option - http://www.randyfay.com/node/93
- More to come!
Issue Queue Commands
- drush iq-info $issuenumber
- drush iq-apply-patch $issuecommentnumber (?)
- drush cache-set blah "blah string"
- drush cache-get schema --format=json
- drush entity-show $id - like print_r on an entity!
- drush entity-delete
- drush entity-edit $entity-type $id -- EDIT AN ENTITY FROM THE CLI
- drush entity-show 1 --json | drush entity-create - (not sure of format exactly but think this is a way that you can copy an existing node via drush, EVEN BETWEEN SITES using aliases!
- drush entity-show can be piped through mail to send a node to someone!
- Currently, commands run on a group of site aliases execute in series.
- This is slower than deploying all at the same time (i.e. parallelization)
- Issue is up in drush queue and there is a patch: $1053072
- Really really close to what Capistrano does; could soon have a drush deploy module that does it (without Ruby)!
- Aegir problem has tackled a lot of these problems and they'll probably steal what they can
- maintained on github for now
- 35% coverage so far, aiming for everything on Drush 5 but working on a lot in Drush 4
- Automated testing with Jenkins