 (defn -main
   "Takes a MySQL database connection configuration and a directory to output
   the Phinx migrations."
-  [host dbname user pass directory & more]
+  [host dbname user pass schema directory & more]
   (let [db {:subprotocol "mysql"
             :subname (str "//" host ":3306/" dbname)
             :user user
             :password pass}
-        tables (map #(table-data db %)
-                    (tables-info db tablenames))]
+        tables (map #(table-data db schema %)
+                    (describe-tables db tablenames))]
     (doseq [table tables]
       (let [fcontent (render-migration-content table)
             fname    (migration-filename (:table-name table))

                        (remove #(= table-data %)))

        fks        (->> (:name table-data)
                        (schema-info db)
                        (map (fn [info]
                               {:col-name            (:column_name info)
                                :referenced-table    (:referenced_table_name info)

  (let [col-type (column-type column)]
    {:name    (:field column)
     :type    col-type
     :options (cond-> [["null" (= "YES" (:null column))]]
                (= "enum" col-type)                  (conj ["values" (enum-values column)])
                (not (str/blank? (:default column))) (conj ["default" (:default column)]))}))

(defn camelize-table [table-name]
  (let [parts (str/split table-name #"_")]
    (reduce str (map str/capitalize parts))))

(defn table-data [db schema table]
  (let [pk-entry   (->> table
                        (filter #(= (:key %) "PRI"))
                        first)
