procession/procession — pull request #19 by jaypipes (2014-01-27 01:17:36+00:00)
Title: Make organization slug include parent slug

This patch changes the way that organization slugs are
constructed and the indexing on the organization table to ensure
that there are proper indexes on all frequently search attributes.

We put a unique constraint over:

organizations (org_name, parent_organization_id)

Which serves to enforce the uniqueness contract we want, which is
that no two organizations that have the same parent or no parent
share the same organization name.

In order to make the slug field unique, we change the construction
of the slug field for organizations to prepend the parent
organization's slug field to the organization name of the new node.
This essentially makes the slug field into a sort of path enumeration
model, enabling URIs for organizations that model the organization
tree that the organization is contained in.

For example, assume this set of organization tree:

A1 -> B1 -> C1

Then the URI with slug for C1 would be:

GET /organizations/a1-b1-c1