X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FGameInfo.hs;h=3062f5a2b79a1d826a649ccc4c5cba7c9b98fe08;hb=32147474ba5c91452eeb532381f63e88c257a982;hp=2830295a78d16d898989d0d45df94858c760e3f1;hpb=c8ec4174a46c44215ef9540a9b19b99323fb0717;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/GameInfo.hs b/src/TSN/XML/GameInfo.hs index 2830295..3062f5a 100644 --- a/src/TSN/XML/GameInfo.hs +++ b/src/TSN/XML/GameInfo.hs @@ -26,10 +26,8 @@ import Data.Time.Clock ( UTCTime ) import Database.Groundhog ( countAll, insert_, - migrate, - runMigration, - silentMigrationLogger ) -import Database.Groundhog.Generic ( runDbConn ) + migrate ) +import Database.Groundhog.Generic ( runDbConn, runMigrationSilent ) import Database.Groundhog.Sqlite ( withSqliteConn ) import Database.Groundhog.TH ( defaultCodegenConfig, @@ -102,8 +100,9 @@ data GameInfo = -- They provide foreign keys into any tables storing -- games with their IDs. - schedule_id :: Int, -- ^ Required foreign key into any table storing a - -- schedule along with its ID. + schedule_id :: Maybe Int, -- ^ Optional key into any table storing a + -- schedule along with its ID. We've noticed + -- them missing in e.g. recapxml.dtd documents. time_stamp :: UTCTime, xml :: String } deriving (Eq, Show) @@ -190,7 +189,7 @@ test_accessors = testCase "we can access a parsed game_info" $ do let a4 = game_id t let ex4 = Just 39978 let a5 = schedule_id t - let ex5 = 39978 + let ex5 = Just 39978 let a6 = take 9 (xml t) let ex6 = "" let actual = (a1,a2,a3,a4,a5,a6) @@ -233,7 +232,7 @@ test_dbimport_succeeds = testCase "dbimport succeeds" $ do xmltrees <- mapM unsafe_read_document game_info_test_files let msgs = rights $ map (parse_xml "dummy") xmltrees actual <- withSqliteConn ":memory:" $ runDbConn $ do - runMigration silentMigrationLogger $ + runMigrationSilent $ migrate (undefined :: GameInfo) mapM_ dbimport msgs countAll (undefined :: GameInfo)