]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/GameInfo.hs
Update all silent migrations for groundhog-0.7.
[dead/htsn-import.git] / src / TSN / XML / GameInfo.hs
index 2830295a78d16d898989d0d45df94858c760e3f1..3062f5a2b79a1d826a649ccc4c5cba7c9b98fe08 100644 (file)
@@ -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 = "<message>"
   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)