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 initJournal
|
||||||
execute_ conn initRole
|
execute_ conn initRole
|
||||||
execute_ conn initUserToRole
|
execute_ conn initUserToRole
|
||||||
void $ runInsertInitialRole conn
|
void $ runInsertInitialRoles conn
|
||||||
-- validate Migrations
|
-- validate Migrations
|
||||||
let migLoc = T.unpack tMigLoc
|
let migLoc = T.unpack tMigLoc
|
||||||
ok <- withTransaction conn $ runMigration $ MigrationContext
|
ok <- withTransaction conn $ runMigration $ MigrationContext
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Data.Profunctor.Product (p2, p13)
|
||||||
import Opaleye as O hiding (null, not)
|
import Opaleye as O hiding (null, not)
|
||||||
import Opaleye.Constant as C
|
import Opaleye.Constant as C
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
@ -107,13 +108,13 @@ userToRoleTable = table "user_to_role" (
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
insertInitialRole :: PGS.Connection -> MateHandler [Int]
|
insertInitialRoles :: PGS.Connection -> MateHandler ()
|
||||||
insertInitialRole conn =
|
insertInitialRoles conn =
|
||||||
liftIO $ runInsertInitialRole conn
|
void $ liftIO $ runInsertInitialRoles conn
|
||||||
|
|
||||||
runInsertInitialRole :: PGS.Connection -> IO [Int]
|
runInsertInitialRoles :: PGS.Connection -> IO [Int]
|
||||||
runInsertInitialRole conn =
|
runInsertInitialRoles conn = do
|
||||||
runInsert_ conn $ Insert
|
a <- runInsert_ conn $ Insert
|
||||||
{ iTable = roleTable
|
{ iTable = roleTable
|
||||||
, iRows =
|
, iRows =
|
||||||
[
|
[
|
||||||
|
@ -132,6 +133,29 @@ runInsertInitialRole conn =
|
||||||
, C.constant True
|
, C.constant True
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
, iReturning = rReturning (\(id_, _, _, _, _, _, _, _, _, _, _, _, _) -> id_)
|
, iReturning = rReturning (\(id_, _, _, _, _, _, _, _, _, _, _, _, _) -> id_ )
|
||||||
, iOnConflict = Nothing
|
, 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