A simple migrations function for use with caveman.
Posted on September 5, 2015
by blasut
Super simple function I’ve been using in a caveman project. You have to create the “migrations” folder first.
(defun new-migration (name)
"Creates a new migration sql file."
(let* ((fixed-name (cl-ppcre:regex-replace-all "\\s" (string-downcase name) "-"))
(timestamp (write-to-string (local-time:timestamp-to-unix (local-time:now))))
(file-name (concatenate 'string "migrations/" timestamp "-" fixed-name ".sql")))
(with-open-file (file file-name
:direction :output
:if-does-not-exist :create)
(format file "Write your sql here"))))