move initDB to library

This commit is contained in:
nek0 2021-02-01 02:25:08 +01:00
parent a7cc24b73a
commit 45629d0abb

View file

@ -7,5 +7,26 @@ import Data.Maybe (fromMaybe)
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 = 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