                                 set)
         players-to-default (difference players-with-names players-with-roles)
         transaction        (map (fn [id] {:db/id id :user/role :user}) players-to-default)]
-    (info {:ensure-players-users-have-roles transaction})
+    (info "Players changed:" (count players-to-default))
     @(d/transact conn transaction)))
 
 (defn- get-leagues [dbc]

        players-to-give-a-league (difference players-with-names players-with-leagues)
        transaction              (map (fn [pid] {:db/id pid :player/leagues (:id  default-league)})
                                      players-to-give-a-league)]
    (info (merge {:ensure-all-players-have-atleast-one-league players-to-give-a-league
                  :count (count players-to-give-a-league)}
                 (util/symbols-as-map default-league)))
    @(d/transact conn transaction)))

(defn- ensure-all-matches-happened-in-a-league [conn]
  (let [dbc                      (db conn)
        default-league           (get-default-league dbc)
        matches-played           (->> (d/q '[:find ?mid :where [?mid :match/time _]] dbc)

        matches-to-give-a-league (difference matches-played matches-with-leagues)
        transaction              (map (fn [mid] {:db/id mid :match/league (:id default-league)})
                                      matches-to-give-a-league)]
    (info "Matches changed:" (count matches-to-give-a-league))
    @(d/transact conn transaction)))

(def migrations "seq of idempotent migration functions"
  [#'ensure-players-users-have-roles
   #'ensure-atleast-one-league-exists
   #'ensure-all-players-have-atleast-one-league
   #'ensure-all-matches-happened-in-a-league])

(defn migrate-schema-and-data [conn]
  (doseq [migration-var migrations]
    (info "Running migration:" (:doc (meta migration-var)))
    (migration-var conn)))
