Open jedahu opened 12 years ago
I'm pulling this, it needs more thought...
This is a good idea, and I've wanted something like it in the past. I'm reopening the issue. Hopefully you, me, or someone else will think up a proper design/api soon.
Leaving breadcrumbs here: According to some CouchDB folks on IRC (rnewson and jan), views aren't actually reindexed unless a hash of the working parts of the design document-- map, reduce, language, includes, etc.-- changes. The filename of the design doc on disk is that hash.
So that reduces the need for versioning; you can blindly (save-view) in clutch endlessly and it won't reindex or rebuild those views unless that hash changes. If (save-view) returns a new _rev, I'm told that's just a pointer to the same document, because it wasn't any different than the old one (if I'm understanding this correctly).
it still would be good to have view revisions that sync with the source code revisions, and it's good to know that adding another custom revision to a design document won't actually cause anything to get reindexed.
But for my purposes, just brute-force running (save-view) on all my views in a function that runs at every deploy works for the moment.
Ah. Good to know. In the long term I'd still like versioning because among other things, it protects against accidental downgrades.
Added a :code-version key to the options of view-server-fns. If the existing document contains a :code-version field, save-design-document will only update to the new document if its :code-version value is greater. Otherwise the existing document is returned.