anna fedoruk.theworkflow.drupalcamp kyiv 2011

32
Drupal development: The workflow Anna Fedoruk, Sterno.ru

Upload: campdrupalua

Post on 17-Dec-2014

1.442 views

Category:

Technology


4 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Drupal development: The workflow

Anna Fedoruk, Sterno.ru

Page 2: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Gold Sponsor ofDrupalCamp Kyiv 2011

Page 3: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Silver Sponsors ofDrupalCamp Kyiv 2011

Page 4: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Table of contents

1.Dark side of Drupal's power

2.What's the problem and how to deal with

settings in DB

3.Approach 1: migraine-powered workflow

4.Approach 2: features-driven development

Page 5: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Why developers cry?

Drupal is great:• Flexible• Build whatever you want• Powerful tools like CCK, Views, Rules, Panles

etc.So what's the problem?

Page 6: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Why developers cry?

OMG, the settings in DB!• Enabled modules and their settings• Blocks, taxonomy vocabularies, CCK content

types• User roles, permissions• Views, Rules, Contexts, Panels...

Page 7: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Why developers cry?

Migrations of DB-ed settings are very time-consuming, boring and error-prone

Page 8: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

What can we do?

We need to:• Track configuration changes• Migrate these changes

Approaches:• Migrate changes in DB via versioned dumps• Move settings into code: Features ecosystem

Page 9: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

The developer's best friend: Drush

Tons of useful tools:• Modules enabling, disabling, downloading• Updates• Cache clearing• Dumps, backups, sync• ...• + modules add-ons

Page 10: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Approach 1: versioned DB dumps

Page 11: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Our experience with Migraine

• Migraine by Noosphere Networks http://ashearer.com/software/server-administration/migraine

• D6 modification by mukesh.agarwal17 http://www.blisstering.com/migraine-synchronize-your-

development-staging-and-production-sites-databases-drupal-6

• drush• drush add-on by Danil Semelenov

Page 12: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

The point of Migraine

Migraine knows how to deal with different types of

tables:• Config tables• Content tables• Temporary tables• Cache tables• Ignore tables

Page 13: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Migraine Drush add-on

A wrapper for migraine commands:• Create local DB dump• Restore DB from local dump• Full site migration including source code and DB• Sync files on local server with remote server

Page 14: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Migraine: workflow

Developer 1:• Works with code and

configuration• Makes special dump • Lets Migraine know

about new tables (if

any)• commit, push

Developer 2:• pull• Restores from special

dump• Config migrates!

Page 15: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Migraine: workflow

Migration from @dev to @test:• Make special dump• Sync files• Migrate DB

Migration from @dev to @prod:• Migration doesn't affect content tables• Manually correct content tables schema

Page 16: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Migraine: pros and cons

Advantages:• As all tables are classified, no need to think • Doesn't require anything from components

Disadvantages:• Hard to resolve conflicts in dumps• Chaos reigns• In fact you still need to think

Page 17: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Approach 2: code-driven development

Page 18: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features: the idea

Image source: http://developmentseed.org/blog/2009/may/29/making-and-using-features-drupal

Page 19: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features

• Code-driven development: put all the settings

into code • Features know how to deal with Views, CCK,

Imagecahe, node types, user roles and

permissions, Panels, Contexts, Rules and more

Page 20: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features ecosystem

• Features • Ctools exportables• Strongarm — variables• Boxes — custom blocks (replaces core «add

block») • Context — blocks, breadcrumbs and so on • Diff — a tool for work with features states

Page 21: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Feature is a module

• .info — meta-info, dependencies• .module — place your code here• .install — usual install file• .features.inc

Configuration blocks:• feature_name.<smthng>.inc — generated by

Features module

Page 22: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Feature state can be:

• Default — config in code = config in DB• Overriden — config in code != config in DB

(needs revert or update)• Needs review — config in code != config in DB,

code was changed

Page 23: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

A feature workflow

Developer 1• Creates feature• Enables feature• Works with config• Updates feature• commit, push

Developer 2• Pull• Enables/revert feature• Config migrates!

Page 24: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features management

• Web UI• Drush commands:

o view features listo creates new featureo updates code state from DBo updates DB state from code (revert)o view differencies between code and DB states

Page 25: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features without UI

To create feature or add component:• Add meta-info and dependencies in .info file• Update feature

Page 26: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

What about our coworkers?

feature is a module, so one can use hook_install()

и hook_update() to:• Enable modules• Add roles, url aliases etc.• Any custom code

hook_update() to share with those who work in the

same time

hook_install() to share with new developers

Page 27: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Contoller feature

• Includes other features as dependencies• hook_install() and hook_updates() relfect

general changes in the site's state

Page 28: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features: The Workflow

Page 29: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features: advantages

• Easy to work with code in VCS• Features are reusable• Beautiful

Page 30: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Features: disadvantages

• Requires more efforts to keep system's state up-

to-date• Complex dependencies• Some components aren't exportable

Page 31: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Useful links

• More about Migraine o http://www.slideshare.net/drupalindia/migraine-drupal-syncing-

your-staging-and-live-sites-presentation

• More about Featureso http://developmentseed.org/blogo http://nuvole.org/blog/code-driven-developmento http://openatrium.com/

Page 32: Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011

Contacts

Anna Fedoruk,

Sterno.ru

[email protected]

@sternodevteam

http://devteam.sterno.ru