move initDB to library
This commit is contained in:
parent
a7cc24b73a
commit
45629d0abb
1 changed files with 21 additions and 0 deletions
21
src/Util.hs
21
src/Util.hs
|
@ -7,5 +7,26 @@ import Data.Maybe (fromMaybe)
|
||||||
|
|
||||||
import Data.Profunctor.Product.Default (Default)
|
import Data.Profunctor.Product.Default (Default)
|
||||||
|
|
||||||
|
import Database.PostgreSQL.Simple
|
||||||
|
|
||||||
|
import Control.Monad (void)
|
||||||
|
|
||||||
|
-- internal imports
|
||||||
|
|
||||||
|
import Model
|
||||||
|
|
||||||
printSql :: Default Unpackspec a a => Select a -> IO ()
|
printSql :: Default Unpackspec a a => Select a -> IO ()
|
||||||
printSql = putStrLn . fromMaybe "Empty query" . showSqlForPostgres
|
printSql = putStrLn . fromMaybe "Empty query" . showSqlForPostgres
|
||||||
|
|
||||||
|
initDB :: Connection -> IO ()
|
||||||
|
initDB conn = do
|
||||||
|
execute_ conn initAvatar
|
||||||
|
execute_ conn initUser
|
||||||
|
execute_ conn initProduct
|
||||||
|
execute_ conn initToken
|
||||||
|
execute_ conn initAuthData
|
||||||
|
execute_ conn initAmount
|
||||||
|
execute_ conn initJournal
|
||||||
|
execute_ conn initRole
|
||||||
|
execute_ conn initUserToRole
|
||||||
|
void $ runInsertInitialRoles conn
|
||||||
|
|
Loading…
Reference in a new issue