aboutsummaryrefslogtreecommitdiff
path: root/lib/Persist.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Persist.hs')
-rw-r--r--lib/Persist.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Persist.hs b/lib/Persist.hs
index e463195..371ddd0 100644
--- a/lib/Persist.hs
+++ b/lib/Persist.hs
@@ -47,6 +47,8 @@ import Data.Vector (Vector)
import Database.Persist.Postgresql (SqlBackend)
import GHC.Generics (Generic)
import Web.PathPieces (PathPiece)
+import Fmt
+
newtype Token = Token UUID
deriving newtype
@@ -58,13 +60,14 @@ instance ToSchema Token where
instance ToParamSchema Token where
toParamSchema _ = toParamSchema (Proxy @String)
+deriving newtype instance PersistField Seconds
+deriving newtype instance PersistFieldSql Seconds
+-- deriving newtype instance PathPiece Seconds
+-- deriving newtype instance ToParamSchema Seconds
+
data AmendmentStatus = Cancelled | Added | PartiallyCancelled Int Int
deriving (ToJSON, FromJSON, Generic, Show, Read, Eq)
derivePersistField "AmendmentStatus"
--- instance FromHttpApiData AmendmentStatus where
--- parseUrlPiece "Cancelled" = Right Cancelled
--- parseUrlPiece "Added" = Right Added
--- parseUrlPiece other = Left ("unknown AmendmentStatus: "<>other)
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
-- | tokens which have been issued
@@ -92,8 +95,8 @@ TrainAnchor json sql=tt_trip_anchor
trip TripID
day Day
created UTCTime
- when UTCTime
- delay Int Maybe
+ when Seconds
+ delay Seconds Maybe
msg Text Maybe
deriving Show Generic Eq ToSchema