Vervis.Migration: Replace fromJust in migration #109 with informative error
This commit is contained in:
parent
6d72d676e7
commit
590e3928a5
1 changed files with 11 additions and 4 deletions
|
@ -44,7 +44,7 @@ import Database.Persist.Migration
|
||||||
import Database.Persist.Schema (SchemaT, Migration)
|
import Database.Persist.Schema (SchemaT, Migration)
|
||||||
import Database.Persist.Schema.Types hiding (Entity)
|
import Database.Persist.Schema.Types hiding (Entity)
|
||||||
import Database.Persist.Schema.PostgreSQL (schemaBackend)
|
import Database.Persist.Schema.PostgreSQL (schemaBackend)
|
||||||
import Database.Persist.Sql (SqlBackend, toSqlKey)
|
import Database.Persist.Sql (SqlBackend, toSqlKey, fromSqlKey)
|
||||||
import Text.Blaze.Html (toHtml, preEscapedToHtml)
|
import Text.Blaze.Html (toHtml, preEscapedToHtml)
|
||||||
import Text.Blaze.Html.Renderer.Text
|
import Text.Blaze.Html.Renderer.Text
|
||||||
--import Text.Email.QuasiQuotation (email
|
--import Text.Email.QuasiQuotation (email
|
||||||
|
@ -646,17 +646,24 @@ changes hLocal ctx =
|
||||||
)
|
)
|
||||||
"InboxItem neither remote nor local"
|
"InboxItem neither remote nor local"
|
||||||
"InboxItem both remote and local"
|
"InboxItem both remote and local"
|
||||||
let getValByJust = fmap fromJust . getValBy
|
let getValByJust mkuniq id_ desc = do
|
||||||
|
mval <- getValBy $ mkuniq id_
|
||||||
|
case mval of
|
||||||
|
Nothing ->
|
||||||
|
error $
|
||||||
|
desc ++ show (fromSqlKey id_) ++
|
||||||
|
" isn't the Create of any Message"
|
||||||
|
Just val -> return val
|
||||||
for_ (nub activities) $ \ activity -> do
|
for_ (nub activities) $ \ activity -> do
|
||||||
mid <- case activity of
|
mid <- case activity of
|
||||||
Left obid ->
|
Left obid ->
|
||||||
localMessage2019FillRest <$>
|
localMessage2019FillRest <$>
|
||||||
getValByJust
|
getValByJust
|
||||||
(UniqueLocalMessageCreate2019Fill obid)
|
UniqueLocalMessageCreate2019Fill obid "obiid"
|
||||||
Right ractid ->
|
Right ractid ->
|
||||||
remoteMessage2019FillRest <$>
|
remoteMessage2019FillRest <$>
|
||||||
getValByJust
|
getValByJust
|
||||||
(UniqueRemoteMessageCreate2019Fill ractid)
|
UniqueRemoteMessageCreate2019Fill ractid "ractid"
|
||||||
did <- message2019FillRoot <$> getJust mid
|
did <- message2019FillRoot <$> getJust mid
|
||||||
mt <- getValBy $ UniqueTicketDiscussion2019Fill did
|
mt <- getValBy $ UniqueTicketDiscussion2019Fill did
|
||||||
for_ mt $ \ t -> do
|
for_ mt $ \ t -> do
|
||||||
|
|
Loading…
Reference in a new issue