diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index b801549..2b6a958 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -44,7 +44,7 @@ import Database.Persist.Migration import Database.Persist.Schema (SchemaT, Migration) import Database.Persist.Schema.Types hiding (Entity) 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.Renderer.Text --import Text.Email.QuasiQuotation (email @@ -646,17 +646,24 @@ changes hLocal ctx = ) "InboxItem neither remote nor 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 mid <- case activity of Left obid -> localMessage2019FillRest <$> getValByJust - (UniqueLocalMessageCreate2019Fill obid) + UniqueLocalMessageCreate2019Fill obid "obiid" Right ractid -> remoteMessage2019FillRest <$> getValByJust - (UniqueRemoteMessageCreate2019Fill ractid) + UniqueRemoteMessageCreate2019Fill ractid "ractid" did <- message2019FillRoot <$> getJust mid mt <- getValBy $ UniqueTicketDiscussion2019Fill did for_ mt $ \ t -> do