+ dbmigrate _ =
+ run_dbmigrate $ do
+ migrate (undefined :: Weather)
+ migrate (undefined :: WeatherForecast)
+ migrate (undefined :: WeatherForecastListing)
+ migrate (undefined :: Weather_WeatherForecast)
+ migrate (undefined :: WeatherForecast_WeatherForecastListing)
+
+ dbimport m = do
+ -- The weather database schema has a nice linear structure. First
+ -- we insert the top-level weather record.
+ weather_id <- insert_xml m
+
+ -- Next insert all of the forecasts, one at a time.
+ forM_ (xml_forecasts m) $ \forecast -> do
+ forecast_id <- insert_xml forecast
+
+ -- Map this forecast to its parent weather record.
+ insert_ (Weather_WeatherForecast weather_id forecast_id)
+
+ -- Insert all of this forecast's listings.
+ forM_ (listings $ xml_league forecast) $ \listing -> do
+ listing_id <- insert_xml listing
+
+ -- Map this listing to its parent forecast.
+ insert_ $ WeatherForecast_WeatherForecastListing forecast_id listing_id
+
+ return ImportSucceeded