Guest User

Untitled

a guest
Feb 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. (ns app.migration
  2. (:require [environ.core :refer [env]])
  3. (:import org.flywaydb.core.Flyway
  4. org.flywaydb.core.internal.info.MigrationInfoDumper))
  5.  
  6. ;; Build DB String from the Environment Variables
  7. (def db-url (str "jdbc:postgresql://"
  8. (env :pg-db-host) ":"
  9. (env :pg-db-port) "/" (env :pg-db-name)))
  10.  
  11. ;; Initialize Flyway object
  12. (def flyway
  13. (let [locations (into-array String ["classpath:db/migration"])]
  14. (doto (new Flyway)
  15. (.setDataSource db-url (env :pg-db-user) (env :pg-db-password) (into-array String []))
  16. (.setLocations locations))))
  17.  
  18. (defn migrate [] (.migrate flyway))
  19.  
  20. (defn clean [] (.clean flyway))
  21.  
  22. (defn reset [] (clean) (migrate))
  23.  
  24. (defn info []
  25. (println (MigrationInfoDumper/dumpToAsciiTable (.all (.info flyway)))))
Add Comment
Please, Sign In to add comment