I'm still pondering the 'migration' issue, but I thought I'd share my
current hack to prevent existing design docs from being updated in
production. (I'm not yet comfortable enough with the CouchRest code to
make this into a proper patch, but maybe this will be of use to
someone).
* In my web app, I set :env on the thread to a symbol representing the
current environment.
* I have an intermediate class between ExtendedDocument and my models,
in which I overwrite the update_design_doc class method with the code
below. (i.e. you end up with a hierarchy of MyModel <
IntermediateClass < CouchRest::ExtendedDocument).
* When I deploy changes to the models, as part of my capistrano tasks,
I run a rake task which updates the design docs.
# Writes out a design_doc to a given database, returning the
# updated design doc
def self.update_design_doc(design_doc, db = database)
saved = db.get(design_doc['_id']) rescue nil
if saved
# If the design doc is already there, don't update it in prod mode.
We'll do it manually.
unless Thread.current[:env] && Thread.current[:env] == :production
design_doc['views'].each do |name, view|
saved['views'][name] = view
end
db.save_doc(saved)
end
saved
else
design_doc.database = db
design_doc.save
design_doc
end
end
-Ric
> > > > .
> > > > For more options, visit this group athttp://
> >
groups.google.com/group/couchrest?hl=en
> > > > .
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "CouchRest" group.
> > To post to this group, send email to
couc...@googlegroups.com.
> > To unsubscribe from this group, send email to
> >
couchrest+...@googlegroups.com<
couchrest%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >
http://groups.google.com/group/couchrest?hl=en.