   (println "migrations.033-replace-tags-namespace-and-value-with-tag-key up...")
   (doseq [result (h/query "SELECT * from cmr_tags")]
     (print-message result)
-    (let [{:keys [id metadata]} result
+    (let [{:keys [id metadata deleted native_id]} result
           metadata (-> metadata
                        (util/gzip-blob->string)
                        (edn/read-string))

  (println "NOTE: category field and original native-id cannot be recovered")
  (doseq [result (h/query "SELECT * from cmr_tags")]
    (print-message result)
    (let [{:keys [id metadata]} result
          metadata (-> metadata
                       (util/gzip-blob->string)
                       (edn/read-string))
          tag-key (:tag-key metadata)
          ;; There is no way to properly recover a namespace and value that have a
          ;; "." in the value.
          [_ namespace value] (re-matches #"(.*)\.(.*$)" tag-key)
          native-id (str namespace (char 29) value)
          metadata (-> metadata
                       (assoc :namespace namespace
                              :value value)
                       (dissoc :tag-key)
                       pr-str
                       util/string->gzip-bytes)
          result (assoc result :metadata metadata :native_id native-id)]
      (j/update! (config/db) "cmr_tags" result ["id = ?" id]))))

          {:keys [namespace value tag-key]} metadata
          tag-key (or tag-key
                      (str/lower-case (str namespace "." value)))
          ;; Tombstones don't have metadata so the best we can do is replace the char 29 with a
          ;; dot.
          native-id (if deleted
                      (str/replace native_id (str (char 29)) ".")
                      tag-key)
          metadata (if deleted
                     metadata
                     (-> metadata
                      (assoc :tag-key tag-key)
                      (dissoc :namespace :value :category)))
          metadata (-> metadata
                       pr-str
                       util/string->gzip-bytes)
          result (assoc result :metadata metadata :native_id native-id)]
      (j/update! (config/db) "cmr_tags" result ["id = ?" id]))))


(defn down
  "Migrates the database down from version 33."
