Staging & Deployment
Greg Dunlap
 Senior Programmer
     Palantir.net
The Problem
Traditional Deployment
Traditional Deployment


• Everything is in code
Traditional Deployment


• Everything is in code
• Mature tools to manage the code (svn,
  editors, command line dist. tools)
Traditional Deployment


• Everything is in code
• Mature tools to manage the code (svn,
  editors, command line dist. tools)
• Code moves one way (dev -> qa -> prod)
Drupal Deployment
Drupal Deployment
• Drupal stores a lot in the database
Drupal Deployment
• Drupal stores a lot in the database
• CCK, Views, Settings, Blocks, Content
Drupal Deployment
• Drupal stores a lot in the database
• CCK, Views, Settings, Blocks, Content
• Data moves both ways (dev/configuration
  starts in production and moves out, user-
  generated content starts at prod and
  comes in) so can’t just mysqldump from
  dev
Drupal Deployment
• Drupal stores a lot in the database
• CCK, Views, Settings, Blocks, Content
• Data moves both ways (dev/configuration
  starts in production and moves out, user-
  generated content starts at prod and
  comes in) so can’t just mysqldump from
  dev
• No mature toolset to merge
Content vs. Config
Content vs. Config
• Content and Configuration have very
  different problems
Content vs. Config
• Content and Configuration have very
  different problems
• Content - Primary key problems,
  inconsistent dependencies, some poor APIs
  (although most are better in D7 yay)
Content vs. Config
• Content and Configuration have very
  different problems
• Content - Primary key problems,
  inconsistent dependencies, some poor APIs
  (although most are better in D7 yay)
• Config - Wildly inconsistent storage and
  exportability, plus a lot of the above too
hook_form_alter()
hook_form_alter()

• The cause of, and solution to, all life’s
  problems.
hook_form_alter()

• The cause of, and solution to, all life’s
  problems.
• Couples back end and front end
hook_form_alter()

• The cause of, and solution to, all life’s
  problems.
• Couples back end and front end
• Makes it difficult for any purely backend
  solution to work consistently
Options That Suck
Options That Suck

• Develop on production
Options That Suck

• Develop on production
• Repeat everything by hand at launch
Options That Suck

• Develop on production
• Repeat everything by hand at launch
• Seriously life is too short
A Better Option
Move stuff traditionally stored in the database into code.
       This is traditionally how people handle it.
Putting it in code
Putting it in code

• Find an import/export mechanism, write an
  update hook.
Putting it in code

• Find an import/export mechanism, write an
  update hook.
• Devel Macro Module (D5 only)
Putting it in code

• Find an import/export mechanism, write an
  update hook.
• Devel Macro Module (D5 only)
• Views / Panels export/import
Putting it in code

• Find an import/export mechanism, write an
  update hook.
• Devel Macro Module (D5 only)
• Views / Panels export/import
• Content Copy
Putting it in code

• Find an import/export mechanism, write an
  update hook.
• Devel Macro Module (D5 only)
• Views / Panels export/import
• Content Copy
• Patterns
Some Links
Some Links

• Programmatic CCK Now Possible
Some Links

• Programmatic CCK Now Possible
• Managing Your Views Code
Some Links

• Programmatic CCK Now Possible
• Managing Your Views Code
• Lullabot - Moving CCK Changes From Dev
  To Live
Pros & Cons
Pros & Cons

• Pro - Maintainable through svn and
  deployable through normal tools. Great
  option for developer-only shops
Pros & Cons

• Pro - Maintainable through svn and
  deployable through normal tools. Great
  option for developer-only shops
• Con - Non-technical users left behind. GUI
  does not automatically update code, still
  have to do that by hand.
Interesting Conceptually
      Primary key database hacks
Reserved Key IDs
Reserved Key IDs

• Set auto-inc on dev to start at 1
Reserved Key IDs

• Set auto-inc on dev to start at 1
• Set auto-inc on live to start at 1001
Reserved Key IDs

• Set auto-inc on dev to start at 1
• Set auto-inc on live to start at 1001
• Module to move items over
Reserved Key IDs

• Set auto-inc on dev to start at 1
• Set auto-inc on live to start at 1001
• Module to move items over
• Always have a clear set of IDs
Reserved Key IDs

• Set auto-inc on dev to start at 1
• Set auto-inc on live to start at 1001
• Module to move items over
• Always have a clear set of IDs
• Dave Cohen's blog post
Database Scripts
Database Scripts

• Extension of the reserved number method
Database Scripts

• Extension of the reserved number method
• Keeps database dumps in version control
Database Scripts

• Extension of the reserved number method
• Keeps database dumps in version control
• Merges dev and production data
Database Scripts

• Extension of the reserved number method
• Keeps database dumps in version control
• Merges dev and production data
• DBscripts
Pros & Cons
Pros & Cons

• Pros - Clever outside the box idea. Starts
  to address the great unknown of how to
  deploy nodes, etc.
Pros & Cons

• Pros - Clever outside the box idea. Starts
  to address the great unknown of how to
  deploy nodes, etc.
• Cons - Core hacks, not forward-thinking,
  not always db-portable, not the “Drupal
  way”
Up & Coming
Exportables
Framework for getting data out
Exportables
Exportables
• A part of CTools
Exportables
• A part of CTools
• Exposes a hook you implement to export
  whatever content you have
Exportables
• A part of CTools
• Exposes a hook you implement to export
  whatever content you have
• Need to write your own import stuff
Exportables
• A part of CTools
• Exposes a hook you implement to export
  whatever content you have
• Need to write your own import stuff
• Good: Standardized, consistent
Exportables
• A part of CTools
• Exposes a hook you implement to export
  whatever content you have
• Need to write your own import stuff
• Good: Standardized, consistent
• Bad: Still suffers from form_alter() issue
Features
  Config
Features
Features

• You all went to Robin’s talk right?
Features

• You all went to Robin’s talk right?
• Bundle settings into modules for
  distribution
Features

• You all went to Robin’s talk right?
• Bundle settings into modules for
  distribution
• Built on exportables concept
Features

• You all went to Robin’s talk right?
• Bundle settings into modules for
  distribution
• Built on exportables concept
• Coverage is small but growing
Deploy
 Content
Concept
Concept
• Inspired by Services module
Concept
• Inspired by Services module
• API - Manages Deployment Plans and Servers
Concept
• Inspired by Services module
• API - Manages Deployment Plans and Servers
• Modules integrate with API
Concept
• Inspired by Services module
• API - Manages Deployment Plans and Servers
• Modules integrate with API
• Services receive and manage deployed data
Concept
• Inspired by Services module
• API - Manages Deployment Plans and Servers
• Modules integrate with API
• Services receive and manage deployed data
• Implements UUIDs to alleviate primary key
  issues
Concept
• Inspired by Services module
• API - Manages Deployment Plans and Servers
• Modules integrate with API
• Services receive and manage deployed data
• Implements UUIDs to alleviate primary key
  issues
• Manages dependencies between nodes and
  other Drupal objects (users, taxonomy, etc.)
Demo Here
Demo Here


• w00t
Problems
Problems

• Revisioning
Problems

• Revisioning
• Rollback (unless you count mysqldump)
Problems

• Revisioning
• Rollback (unless you count mysqldump)
• Can’t do unattended deployments
Problems

• Revisioning
• Rollback (unless you count mysqldump)
• Can’t do unattended deployments
• Gaps in support (upload.module,
  translations, blocks, etc.)
Conclusions
Conclusions

• No magic bullets
Conclusions

• No magic bullets
• Investigate, evaluate, plan plan plan
Conclusions

• No magic bullets
• Investigate, evaluate, plan plan plan
• Ask questions
Conclusions

• No magic bullets
• Investigate, evaluate, plan plan plan
• Ask questions
• Get involved!
Further Discussion
Further Discussion

• Deployment Framework Posting
Further Discussion

• Deployment Framework Posting
• Development Seed Features posts
Further Discussion

• Deployment Framework Posting
• Development Seed Features posts
• Change Management Group

Staging and Deployment