As I'm a big fan of factoring things out when possible, I've started
work on a database independent migration library called Ragtime. It
doesn't have functionality for manipulating databases, so would it
would need to be used with a database-manipulation library like Lobos.
I'm not sure what direction you want to take with migrations in Lobos,
but I thought I'd keep you informed of what I'm working on, regarding
migrations.
- James
That sounds an awful lot like Drift: https://github.com/macourtney/drift
Have you considered drift and found it wanting? It's missing all the
nuts-and-bolts that Lobos seems to provide, but they do already seem
very complimentary.
-Phil
I started work on migrations before I knew about Drift, but there are
a few things in Drift I don't like.
I don't like having a migration per file. I'd prefer to put my
migrations in a single file.
I'm also not sold on having a migration per namespace. At first I
thought that a Migration protocol would be a better solution, but
since I've talked to you and hiredman on #clojure, I'm beginning to
think that the best way of representing a migration is via a map:
{:up #(alter :add (table :users (column :email (data-type :varchar 255))))
:down #(alter :drop (table :users (column :email)))}
The advantage of this approach is that we can use functions to
generate migrations:
(defn add-column [tbl-name col-name & definition]
{:up #(alter :add (table tbl-name (apply column col-name definition)))
:down #(alter :drop (table tbl-name (column col-name)))})
So then the migration becomes:
(add-column :users :email (data-type :varchar 255))
- James