Skip to content

Commit

Permalink
Fix wrong block to trip relation mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
TsimurSh committed May 20, 2024
1 parent bb0897f commit b51cc9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion core/src/main/java/org/transitclock/domain/structs/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@ public class Block implements Serializable {
// be voluminous and therefore slow. The trips will be read in when
// getTrips() is called.
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "block_to_trip")
@JoinTable(name = "block_to_trip", joinColumns = {
@JoinColumn(name = "block_block_id", referencedColumnName = "block_id"),
@JoinColumn(name = "block_config_rev", referencedColumnName = "config_rev"),
@JoinColumn(name = "block_service_id", referencedColumnName = "service_id")
}, inverseJoinColumns = {
@JoinColumn(name = "trips_trip_id", referencedColumnName = "trip_id"),
@JoinColumn(name = "trips_config_rev", referencedColumnName = "config_rev"),
@JoinColumn(name = "trips_start_time", referencedColumnName = "start_time")
})
@OrderColumn(name = "list_index")
@Cascade({CascadeType.SAVE_UPDATE})
private final List<Trip> trips;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,8 @@ ALTER TABLE trips
ALTER TABLE trips
ADD CONSTRAINT FK_TRIPS_ON_TRCORETRID FOREIGN KEY (tripPattern_config_rev, tripPattern_id) REFERENCES trip_patterns (config_rev, id);

-- ALTER TABLE block_to_trip
-- ADD CONSTRAINT fk_block_to_trip_on_block FOREIGN KEY (block_config_rev, block_block_id, block_service_id) REFERENCES blocks (config_rev, block_id, service_id);
ALTER TABLE block_to_trip
ADD CONSTRAINT fk_block_to_trip_on_block FOREIGN KEY (block_config_rev, block_block_id, block_service_id) REFERENCES blocks (config_rev, block_id, service_id);

ALTER TABLE block_to_trip
ADD CONSTRAINT fk_block_to_trip_on_trip FOREIGN KEY (trips_config_rev, trips_trip_id, trips_start_time) REFERENCES trips (config_rev, trip_id, start_time);
Expand All @@ -672,4 +672,4 @@ ALTER TABLE trip_pattern_to_path
ADD CONSTRAINT fk_tripatern_to_path_on_stop_path FOREIGN KEY (stop_path_trip_pattern_id, stop_path_stop_path_id, stop_path_config_rev) REFERENCES stop_paths (trip_pattern_id, stop_path_id, config_rev);

ALTER TABLE trip_pattern_to_path
ADD CONSTRAINT fk_tripatern_to_path_on_trip_pattern FOREIGN KEY (trip_pattern_id, trip_pattern_config_rev) REFERENCES trip_patterns (id, config_rev);
ADD CONSTRAINT fk_tripatern_to_path_on_trip_pattern FOREIGN KEY (trip_pattern_id, trip_pattern_config_rev) REFERENCES trip_patterns (id, config_rev);

0 comments on commit b51cc9f

Please sign in to comment.