mateamt/src/Util.hs

37 lines
799 B
Haskell
Raw Normal View History

{-# LANGUAGE FlexibleContexts #-}
module Util where
import Opaleye
2019-12-12 02:15:56 +00:00
import Data.Maybe (fromMaybe)
import Data.Profunctor.Product.Default (Default)
2021-02-01 01:25:08 +00:00
import Database.PostgreSQL.Simple
import Control.Monad (void)
-- internal imports
import Model
printSql :: Default Unpackspec a a => Select a -> IO ()
2019-12-12 02:15:56 +00:00
printSql = putStrLn . fromMaybe "Empty query" . showSqlForPostgres
2021-02-01 01:25:08 +00:00
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
2021-06-24 04:33:05 +00:00
-- This is only a dummy function.
-- TODO: Replace with proper translation function(s)!
__ = id