]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/JFile.hs
Update all silent migrations for groundhog-0.7.
[dead/htsn-import.git] / src / TSN / XML / JFile.hs
index b3b3280f097dfad1a0dce9930be3ad093e2d9903..80d13fe8354b5d353f343924e7e9bd9ab6fda90a 100644 (file)
@@ -28,14 +28,13 @@ import Data.List ( intercalate )
 import Data.String.Utils ( split )
 import Data.Time ( UTCTime(..) )
 import Data.Tuple.Curry ( uncurryN )
+import qualified Data.Vector.HFixed as H ( HVector, convert )
 import Database.Groundhog (
   countAll,
   deleteAll,
-  migrate,
-  runMigration,
-  silentMigrationLogger )
+  migrate )
 import Database.Groundhog.Core ( DefaultKey )
-import Database.Groundhog.Generic ( runDbConn )
+import Database.Groundhog.Generic ( runDbConn, runMigrationSilent )
 import Database.Groundhog.Sqlite ( withSqliteConn )
 import Database.Groundhog.TH (
   groundhog,
@@ -62,7 +61,6 @@ import Text.XML.HXT.Core (
 
 
 -- Local imports
-import Generics ( Generic(..), to_tuple )
 import TSN.Codegen ( tsn_codegen_config )
 import TSN.Database ( insert_or_select )
 import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
@@ -127,9 +125,9 @@ data Message =
   deriving (Eq, GHC.Generic, Show)
 
 
--- | For 'Generics.to_tuple'.
+-- | For 'H.convert'.
 --
-instance Generic Message
+instance H.HVector Message
 
 
 instance ToDb Message where
@@ -257,9 +255,9 @@ data JFileGameXml =
   deriving (Eq, GHC.Generic, Show)
 
 
--- | For 'Generics.to_tuple'.
+-- | For 'H.convert'.
 --
-instance Generic JFileGameXml
+instance H.HVector JFileGameXml
 
 
 -- * JFileGameListXml
@@ -435,7 +433,7 @@ mkPersist tsn_codegen_config [groundhog|
 pickle_message :: PU Message
 pickle_message =
   xpElem "message" $
-    xpWrap (from_tuple, to_tuple) $
+    xpWrap (from_tuple, H.convert) $
     xp6Tuple (xpElem "XML_File_ID" xpInt)
              (xpElem "heading" xpText)
              (xpElem "category" xpText)
@@ -460,7 +458,7 @@ pickle_gamelist =
 pickle_game :: PU JFileGameXml
 pickle_game =
   xpElem "game" $
-    xpWrap (from_tuple, to_tuple) $
+    xpWrap (from_tuple, H.convert) $
     xp14Tuple (xpElem "game_id" xpInt)
               (xpElem "schedule_id" xpInt)
               pickle_odds_info
@@ -553,7 +551,7 @@ pickle_home_team =
              (xpOption xpText) -- Yup, some are nameless
   where
     from_tuple = HTeam . (uncurryN Team)
-    to_tuple' (HTeam t) = to_tuple t
+    to_tuple' (HTeam t) = H.convert t
 
 
 -- | (Un)pickle an away team to/from the dual XML/DB representation
@@ -568,7 +566,7 @@ pickle_away_team =
              (xpOption xpText) -- Yup, some are nameless
   where
     from_tuple = VTeam . (uncurryN Team)
-    to_tuple' (VTeam t) = to_tuple t
+    to_tuple' (VTeam t) = H.convert t
 
 
 pickle_status :: PU JFileGameStatus
@@ -663,7 +661,7 @@ test_on_delete_cascade = testGroup "cascading delete tests"
       let c = undefined :: JFileGame
 
       actual <- withSqliteConn ":memory:" $ runDbConn $ do
-                  runMigration silentMigrationLogger $ do
+                  runMigrationSilent $ do
                     migrate a
                     migrate b
                     migrate c