Add with-db.sh script
This commit is contained in:
parent
a499c35d5b
commit
1a6d2cadad
@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Control.Exception (bracket)
|
||||||
|
|
||||||
import qualified Database.PostgreSQL.Opium as Opium
|
import qualified Database.PostgreSQL.Opium as Opium
|
||||||
|
|
||||||
import qualified Yore.DB
|
import qualified Yore.DB
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = bracket (Opium.connect "host=localhost port=5432 user=yore-test dbname=yore-test") Opium.close $ \conn -> do
|
||||||
conn <- Opium.connect "host=localhost port=5432"
|
|
||||||
result <- Yore.DB.getTables conn
|
result <- Yore.DB.getTables conn
|
||||||
|
|
||||||
case result of
|
case result of
|
||||||
|
|||||||
@ -73,6 +73,7 @@
|
|||||||
pkgs.cabal-install
|
pkgs.cabal-install
|
||||||
pkgs.haskellPackages.implicit-hie
|
pkgs.haskellPackages.implicit-hie
|
||||||
pkgs.haskell-language-server
|
pkgs.haskell-language-server
|
||||||
|
pkgs.postgresql
|
||||||
];
|
];
|
||||||
overrides = addOpium;
|
overrides = addOpium;
|
||||||
}).env;
|
}).env;
|
||||||
|
|||||||
14
with-db.sh
Executable file
14
with-db.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
BASE_DIR=$(mktemp -d)
|
||||||
|
export PGDATA="$BASE_DIR/pgdata"
|
||||||
|
|
||||||
|
# On error or exit: Stop the DB server
|
||||||
|
stop_db_server() {
|
||||||
|
pg_ctl stop --wait
|
||||||
|
}
|
||||||
|
trap stop_db_server EXIT
|
||||||
|
|
||||||
|
initdb --username=yore-test --auth=trust
|
||||||
|
pg_ctl start --wait
|
||||||
|
createdb yore-test --username=yore-test
|
||||||
|
|
||||||
|
"$@"
|
||||||
Loading…
x
Reference in New Issue
Block a user