Skip to content

whostolebenfrog/lein-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lein-postgres

Clojars Project

A lein plugin that starts up an "embedded" postgres instance to be used when running tests / during development.

Warning - this project will not work on an M1 Mac. I don't have one yet to verify but it sounds like some issues downstream. Running postgres in a docker container is a good workaround for right now.

Currently targets postgres 10.6 as this is the latest provided by OpenTable.

In effect it works as a wrapper around OpenTable's embedded postgres JUnit helper.

Usage

Add [lein-postgres "0.1.6"] to the plugins vector in your project.clj file.

A postgres instance can then be started with lein postgres

This will start a postgres instance and wait until you send it kill command with ctrl+c

You can also start a postgres instance and run other lein tasks by passing them as a second argument.

lein postgres test

This will start postgres, run your tests (which presumably depend on postgres) before closing postgres and cleaning up.

Config

You can configure lein-postgres with a config map in your project.clj

(defproject  "1.0.0-SNAPSHOT"
  :plugins [[lein-postgres "0.1.2"]]
  :postgres {:port 12345 ;optional, defaults to a random free port
             :clean-data-directory true ;optional, defaults to true - should we cleanup the data directory on close
             :data-directory "/tmp/embeddedpostgres" ;optional, sets the temporary data directory
             :databases ["test_db"] ; optional, creates databases named in this array
             :server-config {"max_connections" "300"}} ;optional, allows you to set additional server config options

See here for more information on additional server-config options.

Thanks

Thanks to OpenTable for the excellent embedded postgres plugin.

License

Copyright © 2019 Ben Griffiths

Distributed under the Eclipse Public License - just like Clojure.

About

Lein plugin to embed postgres

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •