blackwater icon indicating copy to clipboard operation
blackwater copied to clipboard

Log DDL as well

Open sgrove opened this issue 12 years ago • 0 comments

Having implemented a script/bootstrap setup for project that creates a database, migrates through various migrations, inserting a few rows here and there, black.water shines very well on the SQL output. However, it would be great if it also output DDL transformations. This is particularly nice for boxen (but also production) setups where any failure automatically opens a ticket on github with the output. Some example code where it would be nice:

(ns example.migrations.v0
  (:require [clojure.java.jdbc :as j]
            [clojure.java.jdbc.sql :as sql]
            [clojure.java.jdbc.ddl :as ddl]
            [example.db :as db]))

(defn create-metadata-table! [db-conn]
  (j/db-do-commands db-conn
   (ddl/create-table
    :metadata
    [:schema_version "integer"]))
  (j/insert! db-conn :metadata {:schema_version 0}))

(defn migrate! [db-conn]
  (create-metadata-table! db-conn))

The only black.water output from the above will be: INSERT INTO metadata ( schema_version ) VALUES ( ? ) | 0| took:11ms

sgrove avatar Nov 07 '13 00:11 sgrove