CBQE-927: fix upgrade with queries

Change-Id: I51014d3a75a4b1cbe66a659970e48197e915f061
Reviewed-on: http://review.couchbase.org/23774
Reviewed-by: Andrei Baranouski <andrei.baranouski@gmail.com>
Tested-by: Andrei Baranouski <andrei.baranouski@gmail.com>