server: fix MSSQL event trigger next_retry_at

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7173
GitOrigin-RevId: 862ab4136e0df6b7fa1e2db2c3edfffa318452de
This commit is contained in:
paritosh-08 2022-12-13 20:47:05 +05:30 committed by hasura-bot
parent 5b38518a64
commit 3397c041bc

View File

@ -599,10 +599,19 @@ getMaintenanceModeVersionTx = do
-- We wrap the time value in Datetime2, but before we insert it into the
-- event_log table we convert it into UTCTIME using the 'TODATETIMEOFFSET()'
-- sql function.
convertUTCToDatetime2 :: MonadIO m => UTCTime -> m Datetime2
convertUTCToDatetime2 :: UTCTime -> TxE QErr Datetime2
convertUTCToDatetime2 utcTime = do
timezone <- liftIO $ getTimeZone utcTime
let localTime = utcToLocalTime timezone utcTime
-- We are fetching the timezone from the database server as the database
-- server and the hasura might not be hosted in the same timezone.
timeZoneMinutes :: Int <-
singleRowQueryE
HGE.defaultMSSQLTxErrorHandler
[ODBC.sql|
select DATEPART(TZOFFSET, SYSDATETIMEOFFSET());
|]
let timezone = minutesToTimeZone timeZoneMinutes
localTime = utcToLocalTime timezone utcTime -- DB local time
return $ Datetime2 localTime
checkIfTriggerExistsQ ::