diff options
-rw-r--r-- | lib/Persist.hs | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/Persist.hs b/lib/Persist.hs index 3115ce3..9486a1d 100644 --- a/lib/Persist.hs +++ b/lib/Persist.hs @@ -40,12 +40,12 @@ import Data.Pool (Pool) import Data.Time (NominalDiffTime, UTCTime (utctDay), addUTCTime, dayOfWeek, diffUTCTime, - getCurrentTime, nominalDay) + getCurrentTime, nominalDay, TimeOfDay) import Database.Persist.Postgresql (SqlBackend) import GHC.Generics (Generic) import Web.PathPieces (PathPiece) - - +import Data.Vector (Vector) +import Data.Time.Calendar (Day, DayOfWeek (..)) newtype Token = Token UUID deriving newtype @@ -57,8 +57,12 @@ instance ToSchema Token where instance ToParamSchema Token where toParamSchema _ = toParamSchema (Proxy @String) +data AmendmentStatus = Cancelled | Added + deriving (ToJSON, FromJSON, Generic, Show, Read, Eq) +derivePersistField "AmendmentStatus" share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| +-- | tokens which have been issued RunningTrip sql=tt_tracker_token Id Token default=uuid_generate_v4() expires UTCTime @@ -68,12 +72,31 @@ RunningTrip sql=tt_tracker_token TripPing json sql=tt_trip_ping token RunningTripId - latitude Double - longitude Double + lat Double + long Double delay Double timestamp UTCTime deriving Show Generic Eq +Announcements sql=tt_announcements + trip TripID + message Text + day Text + +-- | this table works as calendar_dates.txt in GTFS +ScheduleAmendment json sql=tt_schedule_amendement + trip TripID + day Text + status AmendmentStatus + -- only one special rule per TripID and Day (else incoherent) + TripAndDay trip day + +-- TODO: possible to have regular trips moved in time without changing TripID? +ExtraordinaryTrip sql=tt_extra_trip + trip TripID + day Text + stops (Vector Text) + stopTimes (Vector TimeOfDay) |] instance ToSchema RunningTripId where |