                      (:type target-store)
                      checked-count))))))
 
+(defn check-store-index
+  [[sk sr :as store] batch-size]
+  (try
+    (log/infof "checking store: %s" sk)
+    (check-store sr batch-size)
+    (catch Exception e
+      (if-let [errors (some->> (ex-data e) :error (remove nil?))]
+        (let [message (format (str "The store %s is invalid, certainly a coercion issue "
+                                   "errors: %s")
+                              sk
+                              (pr-str errors))]
+          (log/error message)
+          message)
+        (throw e)))))
+
 (defn check-store-indexes
   "check all new es store indexes"
   [batch-size prefix]

                             batch-size
                             confirm?)
      (when confirm?
        (check-store-indexes batch-size prefix))
      (log/info "migration complete")
      (catch Exception e
        (log/error e "Unexpected error during migration")


    (log/infof "checking stores: %s" (keys current-stores))
    (log/infof "set batch size: %s" batch-size)
    (keep #(check-store-index % batch-size) target-stores)))

(defn -main
  "invoke with lein run -m ctia.task.migrate-es-stores <prefix> <migrations> <batch-size> <confirm?>"
