Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns app.migration
- (:require [environ.core :refer [env]])
- (:import org.flywaydb.core.Flyway
- org.flywaydb.core.internal.info.MigrationInfoDumper))
- ;; Build DB String from the Environment Variables
- (def db-url (str "jdbc:postgresql://"
- (env :pg-db-host) ":"
- (env :pg-db-port) "/" (env :pg-db-name)))
- ;; Initialize Flyway object
- (def flyway
- (let [locations (into-array String ["classpath:db/migration"])]
- (doto (new Flyway)
- (.setDataSource db-url (env :pg-db-user) (env :pg-db-password) (into-array String []))
- (.setLocations locations))))
- (defn migrate [] (.migrate flyway))
- (defn clean [] (.clean flyway))
- (defn reset [] (clean) (migrate))
- (defn info []
- (println (MigrationInfoDumper/dumpToAsciiTable (.all (.info flyway)))))
Add Comment
Please, Sign In to add comment