aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2024-05-16 23:07:51 +0200
committerstuebinm2024-05-16 23:07:51 +0200
commit7aeb39861887bd76ba35e5cf5222ddf08df68045 (patch)
tree5e8ad29995cef57b190fc541cbdf3e2a4f9ca94f
parent403c2c7ade31861c36334f0185b644e38d2dd71f (diff)
Persist: add cascade rules to foreign keys
It turns out persist does support these, they're just not mentioned in the yesod book. (for future reference, the syntax is defined in Database.Persist.Quasi, which does include some documentation [1]) [1] https://hackage.haskell.org/package/persistent-2.14.6.1/docs/Database-Persist-Quasi.html
Diffstat (limited to '')
-rw-r--r--lib/Persist.hs16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/Persist.hs b/lib/Persist.hs
index f722487..637155a 100644
--- a/lib/Persist.hs
+++ b/lib/Persist.hs
@@ -103,7 +103,7 @@ Import sql=tt_imports
date UTCTime
Stop sql=tt_stop
- ticket TicketId
+ ticket TicketId OnDeleteCascade OnUpdateCascade
station StationId
arrival GTFS.Time
departure GTFS.Time
@@ -131,25 +131,23 @@ Tracker sql=tt_tracker_token
deriving Eq Show Generic
TrackerTicket
- ticket TicketId
- tracker TrackerId
+ ticket TicketId OnDeleteCascade OnUpdateCascade
+ tracker TrackerId OnDeleteCascade OnUpdateCascade
UniqueTrackerTicket ticket tracker
-
-- raw frames as received from OBUs
TrainPing json sql=tt_trip_ping
- -- ticket TicketId
- token TrackerId
+ ticket TicketId OnDeleteCascade OnUpdateCascade
+ token TrackerId OnDeleteSetNull OnUpdateCascade
geopos Geopos
timestamp UTCTime
sequence Double
- ticket TicketId
deriving Show Generic Eq
-- status of a train somewhen in time (may be in the future),
-- inferred from trainpings / entered via controlRoom
TrainAnchor json sql=tt_trip_anchor
- ticket TicketId
+ ticket TicketId OnDeleteCascade OnUpdateCascade
created UTCTime
when GTFS.Seconds
sequence Double
@@ -160,7 +158,7 @@ TrainAnchor json sql=tt_trip_anchor
-- TODO: multi-language support?
Announcement json sql=tt_announcements
Id UUID default=uuid_generate_v4()
- ticket TicketId
+ ticket TicketId OnDeleteCascade OnUpdateCascade
header Text
message Text
url Text Maybe