separate migrations for Point and Session
This commit is contained in:
parent
d6719447bb
commit
200c1019c4
@ -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'
|
||||
|
23
lib/Store.hs
23
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
|
||||
|
Loading…
Reference in New Issue
Block a user