 
 
 ;; ## sync-table steps.
+
+;; ### 0) update-table-row-count!
+
+(defn update-table-display-name!
+  "Update the display_name of TABLE if it doesn't exist."
+  [table]
+  {:pre [(integer? (:id table))]}
+  (try
+    (when (nil? (:display_name table))
+      (upd Table (:id table) :display_name (common/name->human-readable-name (:name table))))
+    (catch Throwable e
+      (log/error (color/red (format "Unable to update display_name for %s: %s" (:name table) (.getMessage e)))))))
+
 
 ;; ### 1) update-table-row-count!
 

         mark-category-field!
         mark-no-preview-display-field!
         mark-url-field!
         sync-database-active-tables!
         sync-field!
         sync-table-active-fields-and-pks!


;; Each field-syncing function below should return FIELD with any updates that we made, or nil.
;; That way the next fn in the 'pipeline' won't trample over changes made by the last.

;; ### set-field-display-name-if-needed!

(defn set-field-display-name-if-needed!
  "If FIELD doesn't yet have a `display_name`, calculate one now and set it."
  [field]
  (when (nil? (:display_name field))
    (let [display-name (common/name->human-readable-name (:name field))]
      (log/info (format "Field '%s.%s' has no display_name. Setting it now." (:name @(:table field)) (:name field) display-name))
      (upd Field (:id field) :display_name display-name)
      (assoc field :display_name display-name))))


;; ### mark-url-field!

