   (let [col-type (column-type column)]
     {:name    (:field column)
      :type    col-type
-     :options (if (= "enum" col-type)
-                [["values" (enum-values column)]])}))
+     :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 table]
+(defn table-data [db schema table]
   (let [pk-entry   (->> table
                         (filter #(= (:key %) "PRI"))
                         first)


        $table
        {% for field in fields %}
            {% if field.options %}
            ->addColumn('{{field.name}}', '{{field.type}}', [
                {% for option in field.options %}
                '{{option.0}}' => '{{option.1}}',
                {% endfor %}
            ])
            {% else %}
            ->addColumn('{{field.name}}', '{{field.type}}')
            {% endif %}
        {% endfor %}
        {% for fk in fks %}
            ->addForeignKey('{{fk.col-name}}', '{{fk.referenced-table}}', '{{fk.referenced-col-name}}')

            [clojure.string :as str]
            [selmer.parser :as selmer]))

(defn get-tables
  "Retrieves a list containing all tables in the database."
  [db]
  (j/query db "show tables"))

(defn column-usage
  "Gets all the foreign keys declarations for a particular schema and table."
  [db schema table]
  (j/query db ["select *
                from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
                where table_name = ?
                and referenced_table_name is not null
                and table_schema = ?
                and column_name is not null
                and referenced_column_name is not null
                and constraint_name <> 'PRIMARY'"
               table
               schema]))

(defn describe-tables
  "Retrieves information regarding all the tables passed as argument."
  [db tables]
  (map (fn [table]
         (conj
          (j/query db (str "describe " table))
          {:type "table" :name table :key ""}))
       tables))

(defn column-type
  "Translates the MySQL column type to Phinx column type."
  [{:keys [type]}]
  (cond
    (re-find #"int\(\d+\)" (str type))      "integer"
    (= "datetime" type)                     "datetime"
