-import Database.Groundhog.Core ( PersistBackend )
+import Database.Groundhog (
+ runMigration )
+import Database.Groundhog.Core ( Migration, PersistBackend )
+import Network.Services.TSN.Report ( report_info )
-- | The type that will be returned from every file import attempt.
--
data ImportResult =
ImportFailed String -- ^ Failure with an error message.
-- | The type that will be returned from every file import attempt.
--
data ImportResult =
ImportFailed String -- ^ Failure with an error message.
- | ImportSkipped String -- ^ We processed the file, but didn't import it.
- -- The reason is contained in the second field.
- | ImportSucceeded -- ^ We did import records.
- | ImportUnsupported String -- ^ We didn't know how to process this file.
- -- The second field should contain info.
+
+ | ImportSkipped String -- ^ We processed the file, but didn't import it.
+ -- The reason is contained in the second field.
+
+ | ImportSucceeded -- ^ We did import records.
+
+ | ImportUnsupported String -- ^ We didn't know how to process this file.
+ -- The second field should contain info.
+
-- created/used by the type @a@.
dbmigrate :: (MonadIO m, PersistBackend m) => a -> m ()
-- created/used by the type @a@.
dbmigrate :: (MonadIO m, PersistBackend m) => a -> m ()
dbimport_generic :: (XmlImport a, MonadIO m, PersistBackend m)
=> a
-> m ImportResult
dbimport_generic x = insert_xml x >> return ImportSucceeded
dbimport_generic :: (XmlImport a, MonadIO m, PersistBackend m)
=> a
-> m ImportResult
dbimport_generic x = insert_xml x >> return ImportSucceeded
+
+
+-- | A migration runner that will use our normal info reporting
+-- mechanism.
+run_dbmigrate :: (MonadIO m, PersistBackend m) => Migration m -> m ()
+run_dbmigrate =
+ runMigration pretty_migration_logger
+ where
+ pretty_migration_logger x =
+ report_info ("Migration: " ++ x ++ ";")