Skip to content

Instantly share code, notes, and snippets.

@juxtin
Created May 12, 2015 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juxtin/cbbf39d94c9cfc08f2f4 to your computer and use it in GitHub Desktop.
Save juxtin/cbbf39d94c9cfc08f2f4 to your computer and use it in GitHub Desktop.
create new migratus migration
;; Run with M-x create-migration
(defun current-datestamp ()
;; 2014 01 14 13 17 03
;; %Y %m %d %H %M %S
(let ((datestamp-format "%Y%m%d%H%M%S"))
(format-time-string datestamp-format (current-time))))
(defun create-migration (name directory)
(interactive "sMigration name: \nDWhere?")
(let* ((base (concat (current-datestamp) "-" name))
(up (concat base ".up.sql"))
(down (concat base ".down.sql")))
(shell-command (concat "touch " up))
(shell-command (concat "touch " down))
(message "Created %s and %s" up down)
(find-file up)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment