commit 200c1019c4fba3ecd8330da4de15806dfd59fd0a
parent d6719447bb91bb476376a22373267fda1566b388
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 10 Nov 2024 15:36:10 +0000
separate migrations for Point and Session
Diffstat:
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/app/Main.hs b/app/Main.hs
@@ -159,6 +159,7 @@ connStr = "host=127.0.0.1 port=5432 user=souplesse dbname=souplesse password=sec
main :: IO ()
main = runStderrLoggingT $ withPostgresqlPool connStr 10 $ \pool -> liftIO $ do
runResourceT $ flip runSqlPool pool $ do
- runMigration migrateAll
+ runMigration migrateSession
+ runMigration migrateTrkpt
static' <- static "frontend"
warp 3000 $ Souplesse pool static'
diff --git a/lib/Store.hs b/lib/Store.hs
@@ -13,7 +13,9 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
-module Store (save, fetch, sessions, sessionStartTime, sessionDuration, migrateAll) where
+module Store (save, fetch, sessions, sessionStartTime,
+ sessionDuration, migrateSession, migrateTrkpt
+ ) where
import Control.Exception
import Control.Monad.IO.Class (MonadIO, liftIO)
@@ -43,7 +45,17 @@ connString :: ConnectionString
connString = "host=127.0.0.1 port=5432 user=souplesse dbname=souplesse password=secret"
share
- [mkPersist sqlSettings, mkMigrate "migrateAll"]
+ [mkPersist sqlSettings, mkMigrate "migrateSession"]
+ [persistLowerCase|
+Session
+ startTime UTCTime
+ duration PgInterval
+ draft Bool default=True
+ notes String Maybe
+|]
+
+share
+ [mkPersist sqlSettings, mkMigrate "migrateTrkpt"]
[persistLowerCase|
Trkpt
lat Double
@@ -53,14 +65,9 @@ Trkpt
cadence Int Maybe
power Int Maybe
heartRate Int Maybe
-
-Session
- startTime UTCTime
- duration PgInterval
- draft Bool default=True
- notes String Maybe
|]
+
fromPoint :: Point -> Trkpt
fromPoint p =
let Pos lat lon ele = T.pos p