insert initial role "User"
This commit is contained in:
parent
c07203646d
commit
26caca500d
2 changed files with 32 additions and 8 deletions
|
@ -102,7 +102,7 @@ main = do
|
|||
execute_ conn initJournal
|
||||
execute_ conn initRole
|
||||
execute_ conn initUserToRole
|
||||
void $ runInsertInitialRole conn
|
||||
void $ runInsertInitialRoles conn
|
||||
-- validate Migrations
|
||||
let migLoc = T.unpack tMigLoc
|
||||
ok <- withTransaction conn $ runMigration $ MigrationContext
|
||||
|
|
|
@ -11,6 +11,7 @@ import Data.Profunctor.Product (p2, p13)
|
|||
import Opaleye as O hiding (null, not)
|
||||
import Opaleye.Constant as C
|
||||
|
||||
import Control.Monad
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
|
||||
-- internal imports
|
||||
|
@ -107,13 +108,13 @@ userToRoleTable = table "user_to_role" (
|
|||
)
|
||||
)
|
||||
|
||||
insertInitialRole :: PGS.Connection -> MateHandler [Int]
|
||||
insertInitialRole conn =
|
||||
liftIO $ runInsertInitialRole conn
|
||||
insertInitialRoles :: PGS.Connection -> MateHandler ()
|
||||
insertInitialRoles conn =
|
||||
void $ liftIO $ runInsertInitialRoles conn
|
||||
|
||||
runInsertInitialRole :: PGS.Connection -> IO [Int]
|
||||
runInsertInitialRole conn =
|
||||
runInsert_ conn $ Insert
|
||||
runInsertInitialRoles :: PGS.Connection -> IO [Int]
|
||||
runInsertInitialRoles conn = do
|
||||
a <- runInsert_ conn $ Insert
|
||||
{ iTable = roleTable
|
||||
, iRows =
|
||||
[
|
||||
|
@ -135,3 +136,26 @@ runInsertInitialRole conn =
|
|||
, iReturning = rReturning (\(id_, _, _, _, _, _, _, _, _, _, _, _, _) -> id_ )
|
||||
, iOnConflict = Nothing
|
||||
}
|
||||
b <- runInsert_ conn $ Insert
|
||||
{ iTable = roleTable
|
||||
, iRows =
|
||||
[
|
||||
( C.constant (Nothing :: Maybe Int)
|
||||
, C.constant ("User" :: String)
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
, C.constant False
|
||||
)
|
||||
]
|
||||
, iReturning = rReturning (\(id_, _, _, _, _, _, _, _, _, _, _, _, _) -> id_ )
|
||||
, iOnConflict = Nothing
|
||||
}
|
||||
return $ a ++ b
|
||||
|
|
Loading…
Reference in a new issue