couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Troy Kruthoff <tkruth...@gmail.com>
Subject Re: Best way to "migrate" (a la Rails) Couch documents
Date Fri, 06 Mar 2009 19:25:27 GMT

On Mar 6, 2009, at 10:05 AM, Jason Smith wrote:

> Hi, list.
>
> While I am happy to be learning Couch for a new project, I am still  
> unsure about some tricks that I used with Django and Rails, such as  
> data migration:
>
> For example, suppose I change my code and instead of using a string  
> timestamp in my documents, I would prefer a hash with "day",  
> "month", and "year" keys.  When I deploy the new code into  
> production, obviously I want the data structures to change for all  
> existing documents.
>

Also keep in mind that another option is to "wrap" your json docs in a  
language specific object for access, and you can use this layer to  
this transformation at runtime and leave the data alone.  As for  
querying, couch allows you to emit values to a view (such as a d/m/y  
hash) instead of the timestamp.

This has the obvious advantage of immediate deployment without first  
having to do a migration.  Which by the way, is very similar to how  
attribs can be added or removed, without touching the actual data store.

-- troy



Mime
View raw message