 
 (schema/defn ->company :- common/Company
   "Take a minimal map describing a company and a user and 'fill the blanks'"
-  [company-props user]
-  (let [slug (or (:slug company-props) (slug/find-available-slug (:name company-props) (taken-slugs)))]
-    (-> company-props
-        (assoc :slug slug)
-        (update :currency #(or % "USD"))
-        (assoc :org-id (:org-id user))
-        (complete-real-sections user)
-        (categories-for)
-        (sections-for))))
+  ([company-props user]
+   (->company company-props user (:slug company-props)))
+  ([company-props user slug]
+   (-> company-props
+       (assoc :slug slug)
+       (update :currency #(or % "USD"))
+       (assoc :org-id (:org-id user))
+       (complete-real-sections user)
+       (categories-for)
+       (sections-for))))
 
 (schema/defn ^:private add-updated-at
   "Add `:updated-at` key with `ts` as value to a given section.


(defn taken-slugs
  "Return all slugs which are in use as a set."
  []
  (into reserved-slugs (map :slug (list-companies))))

(defn slug-available?
  "Return true if the slug is not used by any company in the database."
  [slug]
  (not (contains? (taken-slugs) slug)))

;; ----- Validations -----



(schema/defn ^:always-validate create-company!
  "Create a company document in RethinkDB. Add `updated-at` keys where necessary."
  [conn company :- common/Company]
  (let [real-sections (real-sections company)
        ts (common/current-timestamp)
        rs-w-ts (med/map-vals #(add-updated-at % ts) real-sections)]
    (doseq [[_ section] real-sections]
      (common/create-resource conn common/section-table-name section ts))
    (common/create-resource conn table-name (merge company rs-w-ts) ts)))

(defn update-company
  "
