add insert of default administrator role

This commit is contained in:
nek0 2020-05-16 15:33:27 +02:00
parent c98487318a
commit fafa684da4
2 changed files with 30 additions and 0 deletions

View file

@ -91,6 +91,7 @@ main = do
void $ execute_ conn initJournal
void $ execute_ conn initRole
void $ execute_ conn initUserToRole
runInsertInitialRole
forkCleanProcess conn store
withStdoutLogger $ \ilog -> do
let settings = setPort (fromIntegral lport) $

View file

@ -100,3 +100,32 @@ userToRoleTable = table "user_to_role" (
, tableField "role_id"
)
)
insertInitialRole :: PGS.Connection -> MateHandler ()
insertInitialRole conn =
liftIO $ runInsertInitalRole conn
runInsertInitalRole :: PGS.Connection -> IO ()
runInsertInitalRole conn =
runInsert_ conn $ Insert
{ iTable = roleTable
, iRows =
[
( C.constant (Nothing :: Maybe Int)
, C.constant "Administrator"
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
, C.constant True
)
]
, iReturning = rReturning (\(id_, _, _, _, _, _, _, _, _, _, _, _, _) -> id_)
, iOnConflict = Nothing
}