From 6d610e177ba994c083fee67389c04e7dec639d46 Mon Sep 17 00:00:00 2001 From: scrudden Date: Sat, 12 Jan 2019 17:41:33 +0000 Subject: [PATCH 1/4] Add agency_id to primary key for agency. --- .../src/main/java/org/transitclock/db/structs/Agency.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transitclock/src/main/java/org/transitclock/db/structs/Agency.java b/transitclock/src/main/java/org/transitclock/db/structs/Agency.java index aab61664c..121f41b50 100644 --- a/transitclock/src/main/java/org/transitclock/db/structs/Agency.java +++ b/transitclock/src/main/java/org/transitclock/db/structs/Agency.java @@ -55,7 +55,8 @@ public class Agency implements Serializable { // Note: this is the GTFS agency_id, not the usual // Transitime agencyId. - @Column(length=HibernateUtils.DEFAULT_ID_SIZE) + @Column(length=HibernateUtils.DEFAULT_ID_SIZE) + @Id private final String agencyId; @Column From 6373d58f48af9f3fd76973edcf16e95ad640bf5e Mon Sep 17 00:00:00 2001 From: scrudden Date: Sat, 12 Jan 2019 17:54:22 +0000 Subject: [PATCH 2/4] Add database create SQL scripts. These really should be deleted as they should be generated. --- .../ddl_mysql_org_transitime_db_structs.sql | 559 ----------------- .../ddl_oracle_org_transitime_db_structs.sql | 561 ------------------ ...ddl_postgres_org_transitime_db_structs.sql | 561 ------------------ 3 files changed, 1681 deletions(-) diff --git a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql index 819223bd1..e69de29bb 100644 --- a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql @@ -1,559 +0,0 @@ - - create table ActiveRevisions ( - id integer not null auto_increment, - configRev integer, - travelTimesRev integer, - primary key (id) - ); - - create table Agencies ( - configRev integer not null, - agencyName varchar(60) not null, - agencyFareUrl varchar(255), - agencyId varchar(60), - agencyLang varchar(15), - agencyPhone varchar(15), - agencyTimezone varchar(40), - agencyUrl varchar(255), - maxLat double precision, - maxLon double precision, - minLat double precision, - minLon double precision, - primary key (configRev, agencyName) - ); - - create table ArrivalsDepartures ( - DTYPE varchar(31) not null, - vehicleId varchar(60) not null, - tripId varchar(60) not null, - time datetime(3) not null, - stopId varchar(60) not null, - isArrival bit not null, - gtfsStopSeq integer not null, - avlTime datetime(3), - blockId varchar(60), - configRev integer, - directionId varchar(60), - freqStartTime datetime(3), - routeId varchar(60), - routeShortName varchar(60), - scheduledTime datetime(3), - serviceId varchar(60), - stopOrder integer, - stopPathIndex integer, - stopPathLength float, - tripIndex integer, - primary key (vehicleId, tripId, time, stopId, isArrival, gtfsStopSeq) - ); - - create table AvlReports ( - vehicleId varchar(60) not null, - time datetime(3) not null, - assignmentId varchar(60), - assignmentType varchar(40), - driverId varchar(60), - field1Name varchar(60), - field1Value varchar(60), - heading float, - licensePlate varchar(10), - lat double precision, - lon double precision, - passengerCount integer, - passengerFullness float, - source varchar(10), - speed float, - timeProcessed datetime(3), - primary key (vehicleId, time) - ); - - create table Block_to_Trip_joinTable ( - Blocks_serviceId varchar(60) not null, - Blocks_configRev integer not null, - Blocks_blockId varchar(60) not null, - trips_tripId varchar(60) not null, - trips_startTime integer not null, - trips_configRev integer not null, - listIndex integer not null, - primary key (Blocks_serviceId, Blocks_configRev, Blocks_blockId, listIndex) - ); - - create table Blocks ( - serviceId varchar(60) not null, - configRev integer not null, - blockId varchar(60) not null, - endTime integer, - routeIds blob, - startTime integer, - primary key (serviceId, configRev, blockId) - ); - - create table CalendarDates ( - serviceId varchar(60) not null, - date date not null, - configRev integer not null, - exceptionType varchar(2), - primary key (serviceId, date, configRev) - ); - - create table Calendars ( - wednesday bit not null, - tuesday bit not null, - thursday bit not null, - sunday bit not null, - startDate date not null, - serviceId varchar(60) not null, - saturday bit not null, - monday bit not null, - friday bit not null, - endDate date not null, - configRev integer not null, - primary key (wednesday, tuesday, thursday, sunday, startDate, serviceId, saturday, monday, friday, endDate, configRev) - ); - - create table ConfigRevision ( - configRev integer not null, - notes longtext, - processedTime datetime(3), - zipFileLastModifiedTime datetime(3), - primary key (configRev) - ); - - create table DbTest ( - id integer not null, - primary key (id) - ); - - create table FareAttributes ( - fareId varchar(60) not null, - configRev integer not null, - currencyType varchar(3), - paymentMethod varchar(255), - price float, - transferDuration integer, - transfers varchar(255), - primary key (fareId, configRev) - ); - - create table FareRules ( - routeId varchar(60) not null, - originId varchar(60) not null, - fareId varchar(60) not null, - destinationId varchar(60) not null, - containsId varchar(60) not null, - configRev integer not null, - primary key (routeId, originId, fareId, destinationId, containsId, configRev) - ); - - create table Frequencies ( - tripId varchar(60) not null, - startTime integer not null, - configRev integer not null, - endTime integer, - exactTimes bit, - headwaySecs integer, - primary key (tripId, startTime, configRev) - ); - - create table Headway ( - id bigint not null auto_increment, - average double precision, - coefficientOfVariation double precision, - configRev integer, - creationTime datetime(3), - firstDeparture datetime(3), - headway double precision, - numVehicles integer, - otherVehicleId varchar(60), - routeId varchar(60), - secondDeparture datetime(3), - stopId varchar(60), - tripId varchar(60), - variance double precision, - vehicleId varchar(60), - primary key (id) - ); - - create table HoldingTimes ( - id bigint not null auto_increment, - arrivalPredictionUsed bit, - arrivalTime datetime(3), - arrivalUsed bit, - configRev integer, - creationTime datetime(3), - hasD1 bit, - holdingTime datetime(3), - numberPredictionsUsed integer, - routeId varchar(60), - stopId varchar(60), - tripId varchar(60), - vehicleId varchar(60), - primary key (id) - ); - - create table Matches ( - vehicleId varchar(60) not null, - avlTime datetime(3) not null, - atStop bit, - blockId varchar(60), - configRev integer, - distanceAlongSegment float, - distanceAlongStopPath float, - segmentIndex integer, - serviceId varchar(255), - stopPathIndex integer, - tripId varchar(60), - primary key (vehicleId, avlTime) - ); - - create table MeasuredArrivalTimes ( - time datetime(3) not null, - stopId varchar(60) not null, - directionId varchar(60), - headsign varchar(60), - routeId varchar(60), - routeShortName varchar(60), - primary key (time, stopId) - ); - - create table MonitoringEvents ( - type varchar(40) not null, - time datetime(3) not null, - message longtext, - triggered bit, - value double precision, - primary key (type, time) - ); - - create table PredictionAccuracy ( - id bigint not null auto_increment, - affectedByWaitStop bit, - arrivalDepartureTime datetime(3), - directionId varchar(60), - predictedTime datetime(3), - predictionAccuracyMsecs integer, - predictionReadTime datetime(3), - predictionSource varchar(60), - routeId varchar(60), - routeShortName varchar(60), - stopId varchar(60), - tripId varchar(60), - vehicleId varchar(60), - primary key (id) - ); - - create table Predictions ( - id bigint not null auto_increment, - affectedByWaitStop bit, - avlTime datetime(3), - configRev integer, - creationTime datetime(3), - gtfsStopSeq integer, - isArrival bit, - predictionTime datetime(3), - routeId varchar(60), - schedBasedPred bit, - stopId varchar(60), - tripId varchar(60), - vehicleId varchar(60), - primary key (id) - ); - - create table Routes ( - id varchar(60) not null, - configRev integer not null, - color varchar(10), - description longtext, - maxLat double precision, - maxLon double precision, - minLat double precision, - minLon double precision, - hidden bit, - longName varchar(255), - maxDistance double precision, - name varchar(255), - routeOrder integer, - shortName varchar(255), - textColor varchar(10), - type varchar(2), - primary key (id, configRev) - ); - - create table StopPathPredictions ( - id bigint not null auto_increment, - algorithm varchar(255), - creationTime datetime(3), - predictionTime double precision, - startTime integer, - stopPathIndex integer, - travelTime bit, - tripId varchar(60), - vehicleId varchar(255), - primary key (id) - ); - - create table StopPath_locations ( - StopPath_tripPatternId varchar(120) not null, - StopPath_stopPathId varchar(120) not null, - StopPath_configRev integer not null, - lat double precision, - lon double precision, - locations_ORDER integer not null, - primary key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev, locations_ORDER) - ); - - create table StopPaths ( - tripPatternId varchar(120) not null, - stopPathId varchar(120) not null, - configRev integer not null, - breakTime integer, - gtfsStopSeq integer, - lastStopInTrip bit, - layoverStop bit, - maxDistance double precision, - maxSpeed double precision, - pathLength double precision, - routeId varchar(60), - scheduleAdherenceStop bit, - stopId varchar(60), - waitStop bit, - primary key (tripPatternId, stopPathId, configRev) - ); - - create table Stops ( - id varchar(60) not null, - configRev integer not null, - code integer, - hidden bit, - layoverStop bit, - lat double precision, - lon double precision, - name varchar(255), - timepointStop bit, - waitStop bit, - primary key (id, configRev) - ); - - create table Transfers ( - toStopId varchar(60) not null, - fromStopId varchar(60) not null, - configRev integer not null, - minTransferTime integer, - transferType varchar(1), - primary key (toStopId, fromStopId, configRev) - ); - - create table TravelTimesForStopPaths ( - id integer not null auto_increment, - configRev integer, - daysOfWeekOverride smallint, - howSet varchar(5), - stopPathId varchar(120), - stopTimeMsec integer, - travelTimeSegmentLength float, - travelTimesMsec mediumblob, - travelTimesRev integer, - primary key (id) - ); - - create table TravelTimesForTrip_to_TravelTimesForPath_joinTable ( - TravelTimesForTrips_id integer not null, - travelTimesForStopPaths_id integer not null, - listIndex integer not null, - primary key (TravelTimesForTrips_id, listIndex) - ); - - create table TravelTimesForTrips ( - id integer not null auto_increment, - configRev integer, - travelTimesRev integer, - tripCreatedForId varchar(60), - tripPatternId varchar(120), - primary key (id) - ); - - create table TripPattern_to_Path_joinTable ( - TripPatterns_id varchar(120) not null, - TripPatterns_configRev integer not null, - stopPaths_tripPatternId varchar(120) not null, - stopPaths_stopPathId varchar(120) not null, - stopPaths_configRev integer not null, - listIndex integer not null, - primary key (TripPatterns_id, TripPatterns_configRev, listIndex) - ); - - create table TripPatterns ( - id varchar(120) not null, - configRev integer not null, - directionId varchar(60), - maxLat double precision, - maxLon double precision, - minLat double precision, - minLon double precision, - headsign varchar(255), - routeId varchar(60), - routeShortName varchar(80), - shapeId varchar(60), - primary key (id, configRev) - ); - - create table Trip_scheduledTimesList ( - Trip_tripId varchar(60) not null, - Trip_startTime integer not null, - Trip_configRev integer not null, - arrivalTime integer, - departureTime integer, - scheduledTimesList_ORDER integer not null, - primary key (Trip_tripId, Trip_startTime, Trip_configRev, scheduledTimesList_ORDER) - ); - - create table Trips ( - tripId varchar(60) not null, - startTime integer not null, - configRev integer not null, - blockId varchar(60), - directionId varchar(60), - endTime integer, - exactTimesHeadway bit, - headsign varchar(255), - noSchedule bit, - routeId varchar(60), - routeShortName varchar(60), - serviceId varchar(60), - shapeId varchar(60), - tripShortName varchar(60), - travelTimes_id integer, - tripPattern_id varchar(120), - tripPattern_configRev integer, - primary key (tripId, startTime, configRev) - ); - - create table VehicleConfigs ( - id varchar(60) not null, - capacity integer, - crushCapacity integer, - description varchar(255), - nonPassengerVehicle bit, - trackerId varchar(60), - type integer, - primary key (id) - ); - - create table VehicleEvents ( - vehicleId varchar(60) not null, - time datetime(3) not null, - eventType varchar(60) not null, - avlTime datetime(3), - becameUnpredictable bit, - blockId varchar(60), - description longtext, - lat double precision, - lon double precision, - predictable bit, - routeId varchar(60), - routeShortName varchar(60), - serviceId varchar(60), - stopId varchar(60), - supervisor varchar(60), - tripId varchar(60), - primary key (vehicleId, time, eventType) - ); - - create table VehicleStates ( - vehicleId varchar(60) not null, - avlTime datetime(3) not null, - blockId varchar(60), - isDelayed bit, - isForSchedBasedPreds bit, - isLayover bit, - isPredictable bit, - isWaitStop bit, - routeId varchar(60), - routeShortName varchar(80), - schedAdh varchar(50), - schedAdhMsec integer, - schedAdhWithinBounds bit, - tripId varchar(60), - tripShortName varchar(60), - primary key (vehicleId, avlTime) - ); - - create index ArrivalsDeparturesTimeIndex on ArrivalsDepartures (time); - - create index ArrivalsDeparturesRouteTimeIndex on ArrivalsDepartures (routeShortName, time); - - create index AvlReportsTimeIndex on AvlReports (time); - - create index HeadwayIndex on Headway (creationTime); - - create index HoldingTimeIndex on HoldingTimes (creationTime); - - create index AvlTimeIndex on Matches (avlTime); - - create index MeasuredArrivalTimesIndex on MeasuredArrivalTimes (time); - - create index MonitoringEventsTimeIndex on MonitoringEvents (time); - - create index PredictionAccuracyTimeIndex on PredictionAccuracy (arrivalDepartureTime); - - create index PredictionTimeIndex on Predictions (creationTime); - - create index StopPathPredictionTimeIndex on StopPathPredictions (tripId, stopPathIndex); - - create index TravelTimesRevIndex on TravelTimesForTrips (travelTimesRev); - - alter table TripPattern_to_Path_joinTable - add constraint UK_s0gaw8iv60vc17a5ltryqwg27 unique (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev); - - create index VehicleEventsTimeIndex on VehicleEvents (time); - - create index VehicleStateAvlTimeIndex on VehicleStates (avlTime); - - alter table Block_to_Trip_joinTable - add constraint FK_abaj8ke6oh4imbbgnaercsowo - foreign key (trips_tripId, trips_startTime, trips_configRev) - references Trips (tripId, startTime, configRev); - - alter table Block_to_Trip_joinTable - add constraint FK_1c1e1twdap19vq0xkav0amvm - foreign key (Blocks_serviceId, Blocks_configRev, Blocks_blockId) - references Blocks (serviceId, configRev, blockId); - - alter table StopPath_locations - add constraint FK_sdjt3vtd3w0cl07p0doob6khi - foreign key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev) - references StopPaths (tripPatternId, stopPathId, configRev); - - alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable - add constraint FK_hh5uepurijcqj0pyc6e3h5mqw - foreign key (travelTimesForStopPaths_id) - references TravelTimesForStopPaths (id); - - alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable - add constraint FK_9j1s8ewsmokqg4m35wrr29na7 - foreign key (TravelTimesForTrips_id) - references TravelTimesForTrips (id); - - alter table TripPattern_to_Path_joinTable - add constraint FK_s0gaw8iv60vc17a5ltryqwg27 - foreign key (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev) - references StopPaths (tripPatternId, stopPathId, configRev); - - alter table TripPattern_to_Path_joinTable - add constraint FK_qsr8l6u1nelb5pt8rlnei08sy - foreign key (TripPatterns_id, TripPatterns_configRev) - references TripPatterns (id, configRev); - - alter table Trip_scheduledTimesList - add constraint FK_n5et0p70cwe1dwo4m6lq0k4h0 - foreign key (Trip_tripId, Trip_startTime, Trip_configRev) - references Trips (tripId, startTime, configRev); - - alter table Trips - add constraint FK_p1er53449kkfsca6mbnxkdyst - foreign key (travelTimes_id) - references TravelTimesForTrips (id); - - alter table Trips - add constraint FK_676npp7h4bxh8sjcnugnxt5wb - foreign key (tripPattern_id, tripPattern_configRev) - references TripPatterns (id, configRev); diff --git a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql index 6f0c49cc4..e69de29bb 100644 --- a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql @@ -1,561 +0,0 @@ - - create table ActiveRevisions ( - id number(10,0) not null, - configRev number(10,0), - travelTimesRev number(10,0), - primary key (id) - ); - - create table Agencies ( - configRev number(10,0) not null, - agencyName varchar2(60 char) not null, - agencyFareUrl varchar2(255 char), - agencyId varchar2(60 char), - agencyLang varchar2(15 char), - agencyPhone varchar2(15 char), - agencyTimezone varchar2(40 char), - agencyUrl varchar2(255 char), - maxLat double precision, - maxLon double precision, - minLat double precision, - minLon double precision, - primary key (configRev, agencyName) - ); - - create table ArrivalsDepartures ( - DTYPE varchar2(31 char) not null, - vehicleId varchar2(60 char) not null, - tripId varchar2(60 char) not null, - time timestamp not null, - stopId varchar2(60 char) not null, - isArrival number(1,0) not null, - gtfsStopSeq number(10,0) not null, - avlTime timestamp, - blockId varchar2(60 char), - configRev number(10,0), - directionId varchar2(60 char), - freqStartTime timestamp, - routeId varchar2(60 char), - routeShortName varchar2(60 char), - scheduledTime timestamp, - serviceId varchar2(60 char), - stopOrder number(10,0), - stopPathIndex number(10,0), - stopPathLength float, - tripIndex number(10,0), - primary key (vehicleId, tripId, time, stopId, isArrival, gtfsStopSeq) - ); - - create table AvlReports ( - vehicleId varchar2(60 char) not null, - time timestamp not null, - assignmentId varchar2(60 char), - assignmentType varchar2(40 char), - driverId varchar2(60 char), - field1Name varchar2(60 char), - field1Value varchar2(60 char), - heading float, - licensePlate varchar2(10 char), - lat double precision, - lon double precision, - passengerCount number(10,0), - passengerFullness float, - source varchar2(10 char), - speed float, - timeProcessed timestamp, - primary key (vehicleId, time) - ); - - create table Block_to_Trip_joinTable ( - Blocks_serviceId varchar2(60 char) not null, - Blocks_configRev number(10,0) not null, - Blocks_blockId varchar2(60 char) not null, - trips_tripId varchar2(60 char) not null, - trips_startTime number(10,0) not null, - trips_configRev number(10,0) not null, - listIndex number(10,0) not null, - primary key (Blocks_serviceId, Blocks_configRev, Blocks_blockId, listIndex) - ); - - create table Blocks ( - serviceId varchar2(60 char) not null, - configRev number(10,0) not null, - blockId varchar2(60 char) not null, - endTime number(10,0), - routeIds raw(500), - startTime number(10,0), - primary key (serviceId, configRev, blockId) - ); - - create table CalendarDates ( - serviceId varchar2(60 char) not null, - date date not null, - configRev number(10,0) not null, - exceptionType varchar2(2 char), - primary key (serviceId, date, configRev) - ); - - create table Calendars ( - wednesday number(1,0) not null, - tuesday number(1,0) not null, - thursday number(1,0) not null, - sunday number(1,0) not null, - startDate date not null, - serviceId varchar2(60 char) not null, - saturday number(1,0) not null, - monday number(1,0) not null, - friday number(1,0) not null, - endDate date not null, - configRev number(10,0) not null, - primary key (wednesday, tuesday, thursday, sunday, startDate, serviceId, saturday, monday, friday, endDate, configRev) - ); - - create table ConfigRevision ( - configRev number(10,0) not null, - notes varchar2(512 char), - processedTime timestamp, - zipFileLastModifiedTime timestamp, - primary key (configRev) - ); - - create table DbTest ( - id number(10,0) not null, - primary key (id) - ); - - create table FareAttributes ( - fareId varchar2(60 char) not null, - configRev number(10,0) not null, - currencyType varchar2(3 char), - paymentMethod varchar2(255 char), - price float, - transferDuration number(10,0), - transfers varchar2(255 char), - primary key (fareId, configRev) - ); - - create table FareRules ( - routeId varchar2(60 char) not null, - originId varchar2(60 char) not null, - fareId varchar2(60 char) not null, - destinationId varchar2(60 char) not null, - containsId varchar2(60 char) not null, - configRev number(10,0) not null, - primary key (routeId, originId, fareId, destinationId, containsId, configRev) - ); - - create table Frequencies ( - tripId varchar2(60 char) not null, - startTime number(10,0) not null, - configRev number(10,0) not null, - endTime number(10,0), - exactTimes number(1,0), - headwaySecs number(10,0), - primary key (tripId, startTime, configRev) - ); - - create table Headway ( - id number(19,0) not null, - average double precision, - coefficientOfVariation double precision, - configRev number(10,0), - creationTime timestamp, - firstDeparture timestamp, - headway double precision, - numVehicles number(10,0), - otherVehicleId varchar2(60 char), - routeId varchar2(60 char), - secondDeparture timestamp, - stopId varchar2(60 char), - tripId varchar2(60 char), - variance double precision, - vehicleId varchar2(60 char), - primary key (id) - ); - - create table HoldingTimes ( - id number(19,0) not null, - arrivalPredictionUsed number(1,0), - arrivalTime timestamp, - arrivalUsed number(1,0), - configRev number(10,0), - creationTime timestamp, - hasD1 number(1,0), - holdingTime timestamp, - numberPredictionsUsed number(10,0), - routeId varchar2(60 char), - stopId varchar2(60 char), - tripId varchar2(60 char), - vehicleId varchar2(60 char), - primary key (id) - ); - - create table Matches ( - vehicleId varchar2(60 char) not null, - avlTime timestamp not null, - atStop number(1,0), - blockId varchar2(60 char), - configRev number(10,0), - distanceAlongSegment float, - distanceAlongStopPath float, - segmentIndex number(10,0), - serviceId varchar2(255 char), - stopPathIndex number(10,0), - tripId varchar2(60 char), - primary key (vehicleId, avlTime) - ); - - create table MeasuredArrivalTimes ( - time timestamp not null, - stopId varchar2(60 char) not null, - directionId varchar2(60 char), - headsign varchar2(60 char), - routeId varchar2(60 char), - routeShortName varchar2(60 char), - primary key (time, stopId) - ); - - create table MonitoringEvents ( - type varchar2(40 char) not null, - time timestamp not null, - message varchar2(512 char), - triggered number(1,0), - value double precision, - primary key (type, time) - ); - - create table PredictionAccuracy ( - id number(19,0) not null, - affectedByWaitStop number(1,0), - arrivalDepartureTime timestamp, - directionId varchar2(60 char), - predictedTime timestamp, - predictionAccuracyMsecs number(10,0), - predictionReadTime timestamp, - predictionSource varchar2(60 char), - routeId varchar2(60 char), - routeShortName varchar2(60 char), - stopId varchar2(60 char), - tripId varchar2(60 char), - vehicleId varchar2(60 char), - primary key (id) - ); - - create table Predictions ( - id number(19,0) not null, - affectedByWaitStop number(1,0), - avlTime timestamp, - configRev number(10,0), - creationTime timestamp, - gtfsStopSeq number(10,0), - isArrival number(1,0), - predictionTime timestamp, - routeId varchar2(60 char), - schedBasedPred number(1,0), - stopId varchar2(60 char), - tripId varchar2(60 char), - vehicleId varchar2(60 char), - primary key (id) - ); - - create table Routes ( - id varchar2(60 char) not null, - configRev number(10,0) not null, - color varchar2(10 char), - description varchar2(1024 char), - maxLat double precision, - maxLon double precision, - minLat double precision, - minLon double precision, - hidden number(1,0), - longName varchar2(255 char), - maxDistance double precision, - name varchar2(255 char), - routeOrder number(10,0), - shortName varchar2(255 char), - textColor varchar2(10 char), - type varchar2(2 char), - primary key (id, configRev) - ); - - create table StopPathPredictions ( - id number(19,0) not null, - algorithm varchar2(255 char), - creationTime timestamp, - predictionTime double precision, - startTime number(10,0), - stopPathIndex number(10,0), - travelTime number(1,0), - tripId varchar2(60 char), - vehicleId varchar2(255 char), - primary key (id) - ); - - create table StopPath_locations ( - StopPath_tripPatternId varchar2(120 char) not null, - StopPath_stopPathId varchar2(120 char) not null, - StopPath_configRev number(10,0) not null, - lat double precision, - lon double precision, - locations_ORDER number(10,0) not null, - primary key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev, locations_ORDER) - ); - - create table StopPaths ( - tripPatternId varchar2(120 char) not null, - stopPathId varchar2(120 char) not null, - configRev number(10,0) not null, - breakTime number(10,0), - gtfsStopSeq number(10,0), - lastStopInTrip number(1,0), - layoverStop number(1,0), - maxDistance double precision, - maxSpeed double precision, - pathLength double precision, - routeId varchar2(60 char), - scheduleAdherenceStop number(1,0), - stopId varchar2(60 char), - waitStop number(1,0), - primary key (tripPatternId, stopPathId, configRev) - ); - - create table Stops ( - id varchar2(60 char) not null, - configRev number(10,0) not null, - code number(10,0), - hidden number(1,0), - layoverStop number(1,0), - lat double precision, - lon double precision, - name varchar2(255 char), - timepointStop number(1,0), - waitStop number(1,0), - primary key (id, configRev) - ); - - create table Transfers ( - toStopId varchar2(60 char) not null, - fromStopId varchar2(60 char) not null, - configRev number(10,0) not null, - minTransferTime number(10,0), - transferType varchar2(1 char), - primary key (toStopId, fromStopId, configRev) - ); - - create table TravelTimesForStopPaths ( - id number(10,0) not null, - configRev number(10,0), - daysOfWeekOverride number(5,0), - howSet varchar2(5 char), - stopPathId varchar2(120 char), - stopTimeMsec number(10,0), - travelTimeSegmentLength float, - travelTimesMsec long raw, - travelTimesRev number(10,0), - primary key (id) - ); - - create table TravelTimesForTrip_to_TravelTimesForPath_joinTable ( - TravelTimesForTrips_id number(10,0) not null, - travelTimesForStopPaths_id number(10,0) not null, - listIndex number(10,0) not null, - primary key (TravelTimesForTrips_id, listIndex) - ); - - create table TravelTimesForTrips ( - id number(10,0) not null, - configRev number(10,0), - travelTimesRev number(10,0), - tripCreatedForId varchar2(60 char), - tripPatternId varchar2(120 char), - primary key (id) - ); - - create table TripPattern_to_Path_joinTable ( - TripPatterns_id varchar2(120 char) not null, - TripPatterns_configRev number(10,0) not null, - stopPaths_tripPatternId varchar2(120 char) not null, - stopPaths_stopPathId varchar2(120 char) not null, - stopPaths_configRev number(10,0) not null, - listIndex number(10,0) not null, - primary key (TripPatterns_id, TripPatterns_configRev, listIndex) - ); - - create table TripPatterns ( - id varchar2(120 char) not null, - configRev number(10,0) not null, - directionId varchar2(60 char), - maxLat double precision, - maxLon double precision, - minLat double precision, - minLon double precision, - headsign varchar2(255 char), - routeId varchar2(60 char), - routeShortName varchar2(80 char), - shapeId varchar2(60 char), - primary key (id, configRev) - ); - - create table Trip_scheduledTimesList ( - Trip_tripId varchar2(60 char) not null, - Trip_startTime number(10,0) not null, - Trip_configRev number(10,0) not null, - arrivalTime number(10,0), - departureTime number(10,0), - scheduledTimesList_ORDER number(10,0) not null, - primary key (Trip_tripId, Trip_startTime, Trip_configRev, scheduledTimesList_ORDER) - ); - - create table Trips ( - tripId varchar2(60 char) not null, - startTime number(10,0) not null, - configRev number(10,0) not null, - blockId varchar2(60 char), - directionId varchar2(60 char), - endTime number(10,0), - exactTimesHeadway number(1,0), - headsign varchar2(255 char), - noSchedule number(1,0), - routeId varchar2(60 char), - routeShortName varchar2(60 char), - serviceId varchar2(60 char), - shapeId varchar2(60 char), - tripShortName varchar2(60 char), - travelTimes_id number(10,0), - tripPattern_id varchar2(120 char), - tripPattern_configRev number(10,0), - primary key (tripId, startTime, configRev) - ); - - create table VehicleConfigs ( - id varchar2(60 char) not null, - capacity number(10,0), - crushCapacity number(10,0), - description varchar2(255 char), - nonPassengerVehicle number(1,0), - trackerId varchar2(60 char), - type number(10,0), - primary key (id) - ); - - create table VehicleEvents ( - vehicleId varchar2(60 char) not null, - time timestamp not null, - eventType varchar2(60 char) not null, - avlTime timestamp, - becameUnpredictable number(1,0), - blockId varchar2(60 char), - description varchar2(500 char), - lat double precision, - lon double precision, - predictable number(1,0), - routeId varchar2(60 char), - routeShortName varchar2(60 char), - serviceId varchar2(60 char), - stopId varchar2(60 char), - supervisor varchar2(60 char), - tripId varchar2(60 char), - primary key (vehicleId, time, eventType) - ); - - create table VehicleStates ( - vehicleId varchar2(60 char) not null, - avlTime timestamp not null, - blockId varchar2(60 char), - isDelayed number(1,0), - isForSchedBasedPreds number(1,0), - isLayover number(1,0), - isPredictable number(1,0), - isWaitStop number(1,0), - routeId varchar2(60 char), - routeShortName varchar2(80 char), - schedAdh varchar2(50 char), - schedAdhMsec number(10,0), - schedAdhWithinBounds number(1,0), - tripId varchar2(60 char), - tripShortName varchar2(60 char), - primary key (vehicleId, avlTime) - ); - - create index ArrivalsDeparturesTimeIndex on ArrivalsDepartures (time); - - create index ArrivalsDeparturesRouteTimeIndex on ArrivalsDepartures (routeShortName, time); - - create index AvlReportsTimeIndex on AvlReports (time); - - create index HeadwayIndex on Headway (creationTime); - - create index HoldingTimeIndex on HoldingTimes (creationTime); - - create index AvlTimeIndex on Matches (avlTime); - - create index MeasuredArrivalTimesIndex on MeasuredArrivalTimes (time); - - create index MonitoringEventsTimeIndex on MonitoringEvents (time); - - create index PredictionAccuracyTimeIndex on PredictionAccuracy (arrivalDepartureTime); - - create index PredictionTimeIndex on Predictions (creationTime); - - create index StopPathPredictionTimeIndex on StopPathPredictions (tripId, stopPathIndex); - - create index TravelTimesRevIndex on TravelTimesForTrips (travelTimesRev); - - alter table TripPattern_to_Path_joinTable - add constraint UK_s0gaw8iv60vc17a5ltryqwg27 unique (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev); - - create index VehicleEventsTimeIndex on VehicleEvents (time); - - create index VehicleStateAvlTimeIndex on VehicleStates (avlTime); - - alter table Block_to_Trip_joinTable - add constraint FK_abaj8ke6oh4imbbgnaercsowo - foreign key (trips_tripId, trips_startTime, trips_configRev) - references Trips; - - alter table Block_to_Trip_joinTable - add constraint FK_1c1e1twdap19vq0xkav0amvm - foreign key (Blocks_serviceId, Blocks_configRev, Blocks_blockId) - references Blocks; - - alter table StopPath_locations - add constraint FK_sdjt3vtd3w0cl07p0doob6khi - foreign key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev) - references StopPaths; - - alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable - add constraint FK_hh5uepurijcqj0pyc6e3h5mqw - foreign key (travelTimesForStopPaths_id) - references TravelTimesForStopPaths; - - alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable - add constraint FK_9j1s8ewsmokqg4m35wrr29na7 - foreign key (TravelTimesForTrips_id) - references TravelTimesForTrips; - - alter table TripPattern_to_Path_joinTable - add constraint FK_s0gaw8iv60vc17a5ltryqwg27 - foreign key (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev) - references StopPaths; - - alter table TripPattern_to_Path_joinTable - add constraint FK_qsr8l6u1nelb5pt8rlnei08sy - foreign key (TripPatterns_id, TripPatterns_configRev) - references TripPatterns; - - alter table Trip_scheduledTimesList - add constraint FK_n5et0p70cwe1dwo4m6lq0k4h0 - foreign key (Trip_tripId, Trip_startTime, Trip_configRev) - references Trips; - - alter table Trips - add constraint FK_p1er53449kkfsca6mbnxkdyst - foreign key (travelTimes_id) - references TravelTimesForTrips; - - alter table Trips - add constraint FK_676npp7h4bxh8sjcnugnxt5wb - foreign key (tripPattern_id, tripPattern_configRev) - references TripPatterns; - - create sequence hibernate_sequence; diff --git a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql index 33cce163c..e69de29bb 100644 --- a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql @@ -1,561 +0,0 @@ - - create table ActiveRevisions ( - id int4 not null, - configRev int4, - travelTimesRev int4, - primary key (id) - ); - - create table Agencies ( - configRev int4 not null, - agencyName varchar(60) not null, - agencyFareUrl varchar(255), - agencyId varchar(60), - agencyLang varchar(15), - agencyPhone varchar(15), - agencyTimezone varchar(40), - agencyUrl varchar(255), - maxLat float8, - maxLon float8, - minLat float8, - minLon float8, - primary key (configRev, agencyName) - ); - - create table ArrivalsDepartures ( - DTYPE varchar(31) not null, - vehicleId varchar(60) not null, - tripId varchar(60) not null, - time timestamp not null, - stopId varchar(60) not null, - isArrival boolean not null, - gtfsStopSeq int4 not null, - avlTime timestamp, - blockId varchar(60), - configRev int4, - directionId varchar(60), - freqStartTime timestamp, - routeId varchar(60), - routeShortName varchar(60), - scheduledTime timestamp, - serviceId varchar(60), - stopOrder int4, - stopPathIndex int4, - stopPathLength float4, - tripIndex int4, - primary key (vehicleId, tripId, time, stopId, isArrival, gtfsStopSeq) - ); - - create table AvlReports ( - vehicleId varchar(60) not null, - time timestamp not null, - assignmentId varchar(60), - assignmentType varchar(40), - driverId varchar(60), - field1Name varchar(60), - field1Value varchar(60), - heading float4, - licensePlate varchar(10), - lat float8, - lon float8, - passengerCount int4, - passengerFullness float4, - source varchar(10), - speed float4, - timeProcessed timestamp, - primary key (vehicleId, time) - ); - - create table Block_to_Trip_joinTable ( - Blocks_serviceId varchar(60) not null, - Blocks_configRev int4 not null, - Blocks_blockId varchar(60) not null, - trips_tripId varchar(60) not null, - trips_startTime int4 not null, - trips_configRev int4 not null, - listIndex int4 not null, - primary key (Blocks_serviceId, Blocks_configRev, Blocks_blockId, listIndex) - ); - - create table Blocks ( - serviceId varchar(60) not null, - configRev int4 not null, - blockId varchar(60) not null, - endTime int4, - routeIds bytea, - startTime int4, - primary key (serviceId, configRev, blockId) - ); - - create table CalendarDates ( - serviceId varchar(60) not null, - date date not null, - configRev int4 not null, - exceptionType varchar(2), - primary key (serviceId, date, configRev) - ); - - create table Calendars ( - wednesday boolean not null, - tuesday boolean not null, - thursday boolean not null, - sunday boolean not null, - startDate date not null, - serviceId varchar(60) not null, - saturday boolean not null, - monday boolean not null, - friday boolean not null, - endDate date not null, - configRev int4 not null, - primary key (wednesday, tuesday, thursday, sunday, startDate, serviceId, saturday, monday, friday, endDate, configRev) - ); - - create table ConfigRevision ( - configRev int4 not null, - notes varchar(512), - processedTime timestamp, - zipFileLastModifiedTime timestamp, - primary key (configRev) - ); - - create table DbTest ( - id int4 not null, - primary key (id) - ); - - create table FareAttributes ( - fareId varchar(60) not null, - configRev int4 not null, - currencyType varchar(3), - paymentMethod varchar(255), - price float4, - transferDuration int4, - transfers varchar(255), - primary key (fareId, configRev) - ); - - create table FareRules ( - routeId varchar(60) not null, - originId varchar(60) not null, - fareId varchar(60) not null, - destinationId varchar(60) not null, - containsId varchar(60) not null, - configRev int4 not null, - primary key (routeId, originId, fareId, destinationId, containsId, configRev) - ); - - create table Frequencies ( - tripId varchar(60) not null, - startTime int4 not null, - configRev int4 not null, - endTime int4, - exactTimes boolean, - headwaySecs int4, - primary key (tripId, startTime, configRev) - ); - - create table Headway ( - id int8 not null, - average float8, - coefficientOfVariation float8, - configRev int4, - creationTime timestamp, - firstDeparture timestamp, - headway float8, - numVehicles int4, - otherVehicleId varchar(60), - routeId varchar(60), - secondDeparture timestamp, - stopId varchar(60), - tripId varchar(60), - variance float8, - vehicleId varchar(60), - primary key (id) - ); - - create table HoldingTimes ( - id int8 not null, - arrivalPredictionUsed boolean, - arrivalTime timestamp, - arrivalUsed boolean, - configRev int4, - creationTime timestamp, - hasD1 boolean, - holdingTime timestamp, - numberPredictionsUsed int4, - routeId varchar(60), - stopId varchar(60), - tripId varchar(60), - vehicleId varchar(60), - primary key (id) - ); - - create table Matches ( - vehicleId varchar(60) not null, - avlTime timestamp not null, - atStop boolean, - blockId varchar(60), - configRev int4, - distanceAlongSegment float4, - distanceAlongStopPath float4, - segmentIndex int4, - serviceId varchar(255), - stopPathIndex int4, - tripId varchar(60), - primary key (vehicleId, avlTime) - ); - - create table MeasuredArrivalTimes ( - time timestamp not null, - stopId varchar(60) not null, - directionId varchar(60), - headsign varchar(60), - routeId varchar(60), - routeShortName varchar(60), - primary key (time, stopId) - ); - - create table MonitoringEvents ( - type varchar(40) not null, - time timestamp not null, - message varchar(512), - triggered boolean, - value float8, - primary key (type, time) - ); - - create table PredictionAccuracy ( - id int8 not null, - affectedByWaitStop boolean, - arrivalDepartureTime timestamp, - directionId varchar(60), - predictedTime timestamp, - predictionAccuracyMsecs int4, - predictionReadTime timestamp, - predictionSource varchar(60), - routeId varchar(60), - routeShortName varchar(60), - stopId varchar(60), - tripId varchar(60), - vehicleId varchar(60), - primary key (id) - ); - - create table Predictions ( - id int8 not null, - affectedByWaitStop boolean, - avlTime timestamp, - configRev int4, - creationTime timestamp, - gtfsStopSeq int4, - isArrival boolean, - predictionTime timestamp, - routeId varchar(60), - schedBasedPred boolean, - stopId varchar(60), - tripId varchar(60), - vehicleId varchar(60), - primary key (id) - ); - - create table Routes ( - id varchar(60) not null, - configRev int4 not null, - color varchar(10), - description varchar(1024), - maxLat float8, - maxLon float8, - minLat float8, - minLon float8, - hidden boolean, - longName varchar(255), - maxDistance float8, - name varchar(255), - routeOrder int4, - shortName varchar(255), - textColor varchar(10), - type varchar(2), - primary key (id, configRev) - ); - - create table StopPathPredictions ( - id int8 not null, - algorithm varchar(255), - creationTime timestamp, - predictionTime float8, - startTime int4, - stopPathIndex int4, - travelTime boolean, - tripId varchar(60), - vehicleId varchar(255), - primary key (id) - ); - - create table StopPath_locations ( - StopPath_tripPatternId varchar(120) not null, - StopPath_stopPathId varchar(120) not null, - StopPath_configRev int4 not null, - lat float8, - lon float8, - locations_ORDER int4 not null, - primary key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev, locations_ORDER) - ); - - create table StopPaths ( - tripPatternId varchar(120) not null, - stopPathId varchar(120) not null, - configRev int4 not null, - breakTime int4, - gtfsStopSeq int4, - lastStopInTrip boolean, - layoverStop boolean, - maxDistance float8, - maxSpeed float8, - pathLength float8, - routeId varchar(60), - scheduleAdherenceStop boolean, - stopId varchar(60), - waitStop boolean, - primary key (tripPatternId, stopPathId, configRev) - ); - - create table Stops ( - id varchar(60) not null, - configRev int4 not null, - code int4, - hidden boolean, - layoverStop boolean, - lat float8, - lon float8, - name varchar(255), - timepointStop boolean, - waitStop boolean, - primary key (id, configRev) - ); - - create table Transfers ( - toStopId varchar(60) not null, - fromStopId varchar(60) not null, - configRev int4 not null, - minTransferTime int4, - transferType varchar(1), - primary key (toStopId, fromStopId, configRev) - ); - - create table TravelTimesForStopPaths ( - id int4 not null, - configRev int4, - daysOfWeekOverride int2, - howSet varchar(5), - stopPathId varchar(120), - stopTimeMsec int4, - travelTimeSegmentLength float4, - travelTimesMsec bytea, - travelTimesRev int4, - primary key (id) - ); - - create table TravelTimesForTrip_to_TravelTimesForPath_joinTable ( - TravelTimesForTrips_id int4 not null, - travelTimesForStopPaths_id int4 not null, - listIndex int4 not null, - primary key (TravelTimesForTrips_id, listIndex) - ); - - create table TravelTimesForTrips ( - id int4 not null, - configRev int4, - travelTimesRev int4, - tripCreatedForId varchar(60), - tripPatternId varchar(120), - primary key (id) - ); - - create table TripPattern_to_Path_joinTable ( - TripPatterns_id varchar(120) not null, - TripPatterns_configRev int4 not null, - stopPaths_tripPatternId varchar(120) not null, - stopPaths_stopPathId varchar(120) not null, - stopPaths_configRev int4 not null, - listIndex int4 not null, - primary key (TripPatterns_id, TripPatterns_configRev, listIndex) - ); - - create table TripPatterns ( - id varchar(120) not null, - configRev int4 not null, - directionId varchar(60), - maxLat float8, - maxLon float8, - minLat float8, - minLon float8, - headsign varchar(255), - routeId varchar(60), - routeShortName varchar(80), - shapeId varchar(60), - primary key (id, configRev) - ); - - create table Trip_scheduledTimesList ( - Trip_tripId varchar(60) not null, - Trip_startTime int4 not null, - Trip_configRev int4 not null, - arrivalTime int4, - departureTime int4, - scheduledTimesList_ORDER int4 not null, - primary key (Trip_tripId, Trip_startTime, Trip_configRev, scheduledTimesList_ORDER) - ); - - create table Trips ( - tripId varchar(60) not null, - startTime int4 not null, - configRev int4 not null, - blockId varchar(60), - directionId varchar(60), - endTime int4, - exactTimesHeadway boolean, - headsign varchar(255), - noSchedule boolean, - routeId varchar(60), - routeShortName varchar(60), - serviceId varchar(60), - shapeId varchar(60), - tripShortName varchar(60), - travelTimes_id int4, - tripPattern_id varchar(120), - tripPattern_configRev int4, - primary key (tripId, startTime, configRev) - ); - - create table VehicleConfigs ( - id varchar(60) not null, - capacity int4, - crushCapacity int4, - description varchar(255), - nonPassengerVehicle boolean, - trackerId varchar(60), - type int4, - primary key (id) - ); - - create table VehicleEvents ( - vehicleId varchar(60) not null, - time timestamp not null, - eventType varchar(60) not null, - avlTime timestamp, - becameUnpredictable boolean, - blockId varchar(60), - description varchar(500), - lat float8, - lon float8, - predictable boolean, - routeId varchar(60), - routeShortName varchar(60), - serviceId varchar(60), - stopId varchar(60), - supervisor varchar(60), - tripId varchar(60), - primary key (vehicleId, time, eventType) - ); - - create table VehicleStates ( - vehicleId varchar(60) not null, - avlTime timestamp not null, - blockId varchar(60), - isDelayed boolean, - isForSchedBasedPreds boolean, - isLayover boolean, - isPredictable boolean, - isWaitStop boolean, - routeId varchar(60), - routeShortName varchar(80), - schedAdh varchar(50), - schedAdhMsec int4, - schedAdhWithinBounds boolean, - tripId varchar(60), - tripShortName varchar(60), - primary key (vehicleId, avlTime) - ); - - create index ArrivalsDeparturesTimeIndex on ArrivalsDepartures (time); - - create index ArrivalsDeparturesRouteTimeIndex on ArrivalsDepartures (routeShortName, time); - - create index AvlReportsTimeIndex on AvlReports (time); - - create index HeadwayIndex on Headway (creationTime); - - create index HoldingTimeIndex on HoldingTimes (creationTime); - - create index AvlTimeIndex on Matches (avlTime); - - create index MeasuredArrivalTimesIndex on MeasuredArrivalTimes (time); - - create index MonitoringEventsTimeIndex on MonitoringEvents (time); - - create index PredictionAccuracyTimeIndex on PredictionAccuracy (arrivalDepartureTime); - - create index PredictionTimeIndex on Predictions (creationTime); - - create index StopPathPredictionTimeIndex on StopPathPredictions (tripId, stopPathIndex); - - create index TravelTimesRevIndex on TravelTimesForTrips (travelTimesRev); - - alter table TripPattern_to_Path_joinTable - add constraint UK_s0gaw8iv60vc17a5ltryqwg27 unique (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev); - - create index VehicleEventsTimeIndex on VehicleEvents (time); - - create index VehicleStateAvlTimeIndex on VehicleStates (avlTime); - - alter table Block_to_Trip_joinTable - add constraint FK_abaj8ke6oh4imbbgnaercsowo - foreign key (trips_tripId, trips_startTime, trips_configRev) - references Trips; - - alter table Block_to_Trip_joinTable - add constraint FK_1c1e1twdap19vq0xkav0amvm - foreign key (Blocks_serviceId, Blocks_configRev, Blocks_blockId) - references Blocks; - - alter table StopPath_locations - add constraint FK_sdjt3vtd3w0cl07p0doob6khi - foreign key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev) - references StopPaths; - - alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable - add constraint FK_hh5uepurijcqj0pyc6e3h5mqw - foreign key (travelTimesForStopPaths_id) - references TravelTimesForStopPaths; - - alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable - add constraint FK_9j1s8ewsmokqg4m35wrr29na7 - foreign key (TravelTimesForTrips_id) - references TravelTimesForTrips; - - alter table TripPattern_to_Path_joinTable - add constraint FK_s0gaw8iv60vc17a5ltryqwg27 - foreign key (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev) - references StopPaths; - - alter table TripPattern_to_Path_joinTable - add constraint FK_qsr8l6u1nelb5pt8rlnei08sy - foreign key (TripPatterns_id, TripPatterns_configRev) - references TripPatterns; - - alter table Trip_scheduledTimesList - add constraint FK_n5et0p70cwe1dwo4m6lq0k4h0 - foreign key (Trip_tripId, Trip_startTime, Trip_configRev) - references Trips; - - alter table Trips - add constraint FK_p1er53449kkfsca6mbnxkdyst - foreign key (travelTimes_id) - references TravelTimesForTrips; - - alter table Trips - add constraint FK_676npp7h4bxh8sjcnugnxt5wb - foreign key (tripPattern_id, tripPattern_configRev) - references TripPatterns; - - create sequence hibernate_sequence; From 34b4cd8911caf6cab6f0a58a7696dcc82588a417 Mon Sep 17 00:00:00 2001 From: scrudden Date: Sat, 12 Jan 2019 18:00:54 +0000 Subject: [PATCH 3/4] Revert "Add database create SQL scripts. These really should be deleted as they should be generated." This reverts commit 6373d58f48af9f3fd76973edcf16e95ad640bf5e. --- .../ddl_mysql_org_transitime_db_structs.sql | 559 +++++++++++++++++ .../ddl_oracle_org_transitime_db_structs.sql | 561 ++++++++++++++++++ ...ddl_postgres_org_transitime_db_structs.sql | 561 ++++++++++++++++++ 3 files changed, 1681 insertions(+) diff --git a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql index e69de29bb..819223bd1 100644 --- a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql @@ -0,0 +1,559 @@ + + create table ActiveRevisions ( + id integer not null auto_increment, + configRev integer, + travelTimesRev integer, + primary key (id) + ); + + create table Agencies ( + configRev integer not null, + agencyName varchar(60) not null, + agencyFareUrl varchar(255), + agencyId varchar(60), + agencyLang varchar(15), + agencyPhone varchar(15), + agencyTimezone varchar(40), + agencyUrl varchar(255), + maxLat double precision, + maxLon double precision, + minLat double precision, + minLon double precision, + primary key (configRev, agencyName) + ); + + create table ArrivalsDepartures ( + DTYPE varchar(31) not null, + vehicleId varchar(60) not null, + tripId varchar(60) not null, + time datetime(3) not null, + stopId varchar(60) not null, + isArrival bit not null, + gtfsStopSeq integer not null, + avlTime datetime(3), + blockId varchar(60), + configRev integer, + directionId varchar(60), + freqStartTime datetime(3), + routeId varchar(60), + routeShortName varchar(60), + scheduledTime datetime(3), + serviceId varchar(60), + stopOrder integer, + stopPathIndex integer, + stopPathLength float, + tripIndex integer, + primary key (vehicleId, tripId, time, stopId, isArrival, gtfsStopSeq) + ); + + create table AvlReports ( + vehicleId varchar(60) not null, + time datetime(3) not null, + assignmentId varchar(60), + assignmentType varchar(40), + driverId varchar(60), + field1Name varchar(60), + field1Value varchar(60), + heading float, + licensePlate varchar(10), + lat double precision, + lon double precision, + passengerCount integer, + passengerFullness float, + source varchar(10), + speed float, + timeProcessed datetime(3), + primary key (vehicleId, time) + ); + + create table Block_to_Trip_joinTable ( + Blocks_serviceId varchar(60) not null, + Blocks_configRev integer not null, + Blocks_blockId varchar(60) not null, + trips_tripId varchar(60) not null, + trips_startTime integer not null, + trips_configRev integer not null, + listIndex integer not null, + primary key (Blocks_serviceId, Blocks_configRev, Blocks_blockId, listIndex) + ); + + create table Blocks ( + serviceId varchar(60) not null, + configRev integer not null, + blockId varchar(60) not null, + endTime integer, + routeIds blob, + startTime integer, + primary key (serviceId, configRev, blockId) + ); + + create table CalendarDates ( + serviceId varchar(60) not null, + date date not null, + configRev integer not null, + exceptionType varchar(2), + primary key (serviceId, date, configRev) + ); + + create table Calendars ( + wednesday bit not null, + tuesday bit not null, + thursday bit not null, + sunday bit not null, + startDate date not null, + serviceId varchar(60) not null, + saturday bit not null, + monday bit not null, + friday bit not null, + endDate date not null, + configRev integer not null, + primary key (wednesday, tuesday, thursday, sunday, startDate, serviceId, saturday, monday, friday, endDate, configRev) + ); + + create table ConfigRevision ( + configRev integer not null, + notes longtext, + processedTime datetime(3), + zipFileLastModifiedTime datetime(3), + primary key (configRev) + ); + + create table DbTest ( + id integer not null, + primary key (id) + ); + + create table FareAttributes ( + fareId varchar(60) not null, + configRev integer not null, + currencyType varchar(3), + paymentMethod varchar(255), + price float, + transferDuration integer, + transfers varchar(255), + primary key (fareId, configRev) + ); + + create table FareRules ( + routeId varchar(60) not null, + originId varchar(60) not null, + fareId varchar(60) not null, + destinationId varchar(60) not null, + containsId varchar(60) not null, + configRev integer not null, + primary key (routeId, originId, fareId, destinationId, containsId, configRev) + ); + + create table Frequencies ( + tripId varchar(60) not null, + startTime integer not null, + configRev integer not null, + endTime integer, + exactTimes bit, + headwaySecs integer, + primary key (tripId, startTime, configRev) + ); + + create table Headway ( + id bigint not null auto_increment, + average double precision, + coefficientOfVariation double precision, + configRev integer, + creationTime datetime(3), + firstDeparture datetime(3), + headway double precision, + numVehicles integer, + otherVehicleId varchar(60), + routeId varchar(60), + secondDeparture datetime(3), + stopId varchar(60), + tripId varchar(60), + variance double precision, + vehicleId varchar(60), + primary key (id) + ); + + create table HoldingTimes ( + id bigint not null auto_increment, + arrivalPredictionUsed bit, + arrivalTime datetime(3), + arrivalUsed bit, + configRev integer, + creationTime datetime(3), + hasD1 bit, + holdingTime datetime(3), + numberPredictionsUsed integer, + routeId varchar(60), + stopId varchar(60), + tripId varchar(60), + vehicleId varchar(60), + primary key (id) + ); + + create table Matches ( + vehicleId varchar(60) not null, + avlTime datetime(3) not null, + atStop bit, + blockId varchar(60), + configRev integer, + distanceAlongSegment float, + distanceAlongStopPath float, + segmentIndex integer, + serviceId varchar(255), + stopPathIndex integer, + tripId varchar(60), + primary key (vehicleId, avlTime) + ); + + create table MeasuredArrivalTimes ( + time datetime(3) not null, + stopId varchar(60) not null, + directionId varchar(60), + headsign varchar(60), + routeId varchar(60), + routeShortName varchar(60), + primary key (time, stopId) + ); + + create table MonitoringEvents ( + type varchar(40) not null, + time datetime(3) not null, + message longtext, + triggered bit, + value double precision, + primary key (type, time) + ); + + create table PredictionAccuracy ( + id bigint not null auto_increment, + affectedByWaitStop bit, + arrivalDepartureTime datetime(3), + directionId varchar(60), + predictedTime datetime(3), + predictionAccuracyMsecs integer, + predictionReadTime datetime(3), + predictionSource varchar(60), + routeId varchar(60), + routeShortName varchar(60), + stopId varchar(60), + tripId varchar(60), + vehicleId varchar(60), + primary key (id) + ); + + create table Predictions ( + id bigint not null auto_increment, + affectedByWaitStop bit, + avlTime datetime(3), + configRev integer, + creationTime datetime(3), + gtfsStopSeq integer, + isArrival bit, + predictionTime datetime(3), + routeId varchar(60), + schedBasedPred bit, + stopId varchar(60), + tripId varchar(60), + vehicleId varchar(60), + primary key (id) + ); + + create table Routes ( + id varchar(60) not null, + configRev integer not null, + color varchar(10), + description longtext, + maxLat double precision, + maxLon double precision, + minLat double precision, + minLon double precision, + hidden bit, + longName varchar(255), + maxDistance double precision, + name varchar(255), + routeOrder integer, + shortName varchar(255), + textColor varchar(10), + type varchar(2), + primary key (id, configRev) + ); + + create table StopPathPredictions ( + id bigint not null auto_increment, + algorithm varchar(255), + creationTime datetime(3), + predictionTime double precision, + startTime integer, + stopPathIndex integer, + travelTime bit, + tripId varchar(60), + vehicleId varchar(255), + primary key (id) + ); + + create table StopPath_locations ( + StopPath_tripPatternId varchar(120) not null, + StopPath_stopPathId varchar(120) not null, + StopPath_configRev integer not null, + lat double precision, + lon double precision, + locations_ORDER integer not null, + primary key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev, locations_ORDER) + ); + + create table StopPaths ( + tripPatternId varchar(120) not null, + stopPathId varchar(120) not null, + configRev integer not null, + breakTime integer, + gtfsStopSeq integer, + lastStopInTrip bit, + layoverStop bit, + maxDistance double precision, + maxSpeed double precision, + pathLength double precision, + routeId varchar(60), + scheduleAdherenceStop bit, + stopId varchar(60), + waitStop bit, + primary key (tripPatternId, stopPathId, configRev) + ); + + create table Stops ( + id varchar(60) not null, + configRev integer not null, + code integer, + hidden bit, + layoverStop bit, + lat double precision, + lon double precision, + name varchar(255), + timepointStop bit, + waitStop bit, + primary key (id, configRev) + ); + + create table Transfers ( + toStopId varchar(60) not null, + fromStopId varchar(60) not null, + configRev integer not null, + minTransferTime integer, + transferType varchar(1), + primary key (toStopId, fromStopId, configRev) + ); + + create table TravelTimesForStopPaths ( + id integer not null auto_increment, + configRev integer, + daysOfWeekOverride smallint, + howSet varchar(5), + stopPathId varchar(120), + stopTimeMsec integer, + travelTimeSegmentLength float, + travelTimesMsec mediumblob, + travelTimesRev integer, + primary key (id) + ); + + create table TravelTimesForTrip_to_TravelTimesForPath_joinTable ( + TravelTimesForTrips_id integer not null, + travelTimesForStopPaths_id integer not null, + listIndex integer not null, + primary key (TravelTimesForTrips_id, listIndex) + ); + + create table TravelTimesForTrips ( + id integer not null auto_increment, + configRev integer, + travelTimesRev integer, + tripCreatedForId varchar(60), + tripPatternId varchar(120), + primary key (id) + ); + + create table TripPattern_to_Path_joinTable ( + TripPatterns_id varchar(120) not null, + TripPatterns_configRev integer not null, + stopPaths_tripPatternId varchar(120) not null, + stopPaths_stopPathId varchar(120) not null, + stopPaths_configRev integer not null, + listIndex integer not null, + primary key (TripPatterns_id, TripPatterns_configRev, listIndex) + ); + + create table TripPatterns ( + id varchar(120) not null, + configRev integer not null, + directionId varchar(60), + maxLat double precision, + maxLon double precision, + minLat double precision, + minLon double precision, + headsign varchar(255), + routeId varchar(60), + routeShortName varchar(80), + shapeId varchar(60), + primary key (id, configRev) + ); + + create table Trip_scheduledTimesList ( + Trip_tripId varchar(60) not null, + Trip_startTime integer not null, + Trip_configRev integer not null, + arrivalTime integer, + departureTime integer, + scheduledTimesList_ORDER integer not null, + primary key (Trip_tripId, Trip_startTime, Trip_configRev, scheduledTimesList_ORDER) + ); + + create table Trips ( + tripId varchar(60) not null, + startTime integer not null, + configRev integer not null, + blockId varchar(60), + directionId varchar(60), + endTime integer, + exactTimesHeadway bit, + headsign varchar(255), + noSchedule bit, + routeId varchar(60), + routeShortName varchar(60), + serviceId varchar(60), + shapeId varchar(60), + tripShortName varchar(60), + travelTimes_id integer, + tripPattern_id varchar(120), + tripPattern_configRev integer, + primary key (tripId, startTime, configRev) + ); + + create table VehicleConfigs ( + id varchar(60) not null, + capacity integer, + crushCapacity integer, + description varchar(255), + nonPassengerVehicle bit, + trackerId varchar(60), + type integer, + primary key (id) + ); + + create table VehicleEvents ( + vehicleId varchar(60) not null, + time datetime(3) not null, + eventType varchar(60) not null, + avlTime datetime(3), + becameUnpredictable bit, + blockId varchar(60), + description longtext, + lat double precision, + lon double precision, + predictable bit, + routeId varchar(60), + routeShortName varchar(60), + serviceId varchar(60), + stopId varchar(60), + supervisor varchar(60), + tripId varchar(60), + primary key (vehicleId, time, eventType) + ); + + create table VehicleStates ( + vehicleId varchar(60) not null, + avlTime datetime(3) not null, + blockId varchar(60), + isDelayed bit, + isForSchedBasedPreds bit, + isLayover bit, + isPredictable bit, + isWaitStop bit, + routeId varchar(60), + routeShortName varchar(80), + schedAdh varchar(50), + schedAdhMsec integer, + schedAdhWithinBounds bit, + tripId varchar(60), + tripShortName varchar(60), + primary key (vehicleId, avlTime) + ); + + create index ArrivalsDeparturesTimeIndex on ArrivalsDepartures (time); + + create index ArrivalsDeparturesRouteTimeIndex on ArrivalsDepartures (routeShortName, time); + + create index AvlReportsTimeIndex on AvlReports (time); + + create index HeadwayIndex on Headway (creationTime); + + create index HoldingTimeIndex on HoldingTimes (creationTime); + + create index AvlTimeIndex on Matches (avlTime); + + create index MeasuredArrivalTimesIndex on MeasuredArrivalTimes (time); + + create index MonitoringEventsTimeIndex on MonitoringEvents (time); + + create index PredictionAccuracyTimeIndex on PredictionAccuracy (arrivalDepartureTime); + + create index PredictionTimeIndex on Predictions (creationTime); + + create index StopPathPredictionTimeIndex on StopPathPredictions (tripId, stopPathIndex); + + create index TravelTimesRevIndex on TravelTimesForTrips (travelTimesRev); + + alter table TripPattern_to_Path_joinTable + add constraint UK_s0gaw8iv60vc17a5ltryqwg27 unique (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev); + + create index VehicleEventsTimeIndex on VehicleEvents (time); + + create index VehicleStateAvlTimeIndex on VehicleStates (avlTime); + + alter table Block_to_Trip_joinTable + add constraint FK_abaj8ke6oh4imbbgnaercsowo + foreign key (trips_tripId, trips_startTime, trips_configRev) + references Trips (tripId, startTime, configRev); + + alter table Block_to_Trip_joinTable + add constraint FK_1c1e1twdap19vq0xkav0amvm + foreign key (Blocks_serviceId, Blocks_configRev, Blocks_blockId) + references Blocks (serviceId, configRev, blockId); + + alter table StopPath_locations + add constraint FK_sdjt3vtd3w0cl07p0doob6khi + foreign key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev) + references StopPaths (tripPatternId, stopPathId, configRev); + + alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable + add constraint FK_hh5uepurijcqj0pyc6e3h5mqw + foreign key (travelTimesForStopPaths_id) + references TravelTimesForStopPaths (id); + + alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable + add constraint FK_9j1s8ewsmokqg4m35wrr29na7 + foreign key (TravelTimesForTrips_id) + references TravelTimesForTrips (id); + + alter table TripPattern_to_Path_joinTable + add constraint FK_s0gaw8iv60vc17a5ltryqwg27 + foreign key (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev) + references StopPaths (tripPatternId, stopPathId, configRev); + + alter table TripPattern_to_Path_joinTable + add constraint FK_qsr8l6u1nelb5pt8rlnei08sy + foreign key (TripPatterns_id, TripPatterns_configRev) + references TripPatterns (id, configRev); + + alter table Trip_scheduledTimesList + add constraint FK_n5et0p70cwe1dwo4m6lq0k4h0 + foreign key (Trip_tripId, Trip_startTime, Trip_configRev) + references Trips (tripId, startTime, configRev); + + alter table Trips + add constraint FK_p1er53449kkfsca6mbnxkdyst + foreign key (travelTimes_id) + references TravelTimesForTrips (id); + + alter table Trips + add constraint FK_676npp7h4bxh8sjcnugnxt5wb + foreign key (tripPattern_id, tripPattern_configRev) + references TripPatterns (id, configRev); diff --git a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql index e69de29bb..6f0c49cc4 100644 --- a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql @@ -0,0 +1,561 @@ + + create table ActiveRevisions ( + id number(10,0) not null, + configRev number(10,0), + travelTimesRev number(10,0), + primary key (id) + ); + + create table Agencies ( + configRev number(10,0) not null, + agencyName varchar2(60 char) not null, + agencyFareUrl varchar2(255 char), + agencyId varchar2(60 char), + agencyLang varchar2(15 char), + agencyPhone varchar2(15 char), + agencyTimezone varchar2(40 char), + agencyUrl varchar2(255 char), + maxLat double precision, + maxLon double precision, + minLat double precision, + minLon double precision, + primary key (configRev, agencyName) + ); + + create table ArrivalsDepartures ( + DTYPE varchar2(31 char) not null, + vehicleId varchar2(60 char) not null, + tripId varchar2(60 char) not null, + time timestamp not null, + stopId varchar2(60 char) not null, + isArrival number(1,0) not null, + gtfsStopSeq number(10,0) not null, + avlTime timestamp, + blockId varchar2(60 char), + configRev number(10,0), + directionId varchar2(60 char), + freqStartTime timestamp, + routeId varchar2(60 char), + routeShortName varchar2(60 char), + scheduledTime timestamp, + serviceId varchar2(60 char), + stopOrder number(10,0), + stopPathIndex number(10,0), + stopPathLength float, + tripIndex number(10,0), + primary key (vehicleId, tripId, time, stopId, isArrival, gtfsStopSeq) + ); + + create table AvlReports ( + vehicleId varchar2(60 char) not null, + time timestamp not null, + assignmentId varchar2(60 char), + assignmentType varchar2(40 char), + driverId varchar2(60 char), + field1Name varchar2(60 char), + field1Value varchar2(60 char), + heading float, + licensePlate varchar2(10 char), + lat double precision, + lon double precision, + passengerCount number(10,0), + passengerFullness float, + source varchar2(10 char), + speed float, + timeProcessed timestamp, + primary key (vehicleId, time) + ); + + create table Block_to_Trip_joinTable ( + Blocks_serviceId varchar2(60 char) not null, + Blocks_configRev number(10,0) not null, + Blocks_blockId varchar2(60 char) not null, + trips_tripId varchar2(60 char) not null, + trips_startTime number(10,0) not null, + trips_configRev number(10,0) not null, + listIndex number(10,0) not null, + primary key (Blocks_serviceId, Blocks_configRev, Blocks_blockId, listIndex) + ); + + create table Blocks ( + serviceId varchar2(60 char) not null, + configRev number(10,0) not null, + blockId varchar2(60 char) not null, + endTime number(10,0), + routeIds raw(500), + startTime number(10,0), + primary key (serviceId, configRev, blockId) + ); + + create table CalendarDates ( + serviceId varchar2(60 char) not null, + date date not null, + configRev number(10,0) not null, + exceptionType varchar2(2 char), + primary key (serviceId, date, configRev) + ); + + create table Calendars ( + wednesday number(1,0) not null, + tuesday number(1,0) not null, + thursday number(1,0) not null, + sunday number(1,0) not null, + startDate date not null, + serviceId varchar2(60 char) not null, + saturday number(1,0) not null, + monday number(1,0) not null, + friday number(1,0) not null, + endDate date not null, + configRev number(10,0) not null, + primary key (wednesday, tuesday, thursday, sunday, startDate, serviceId, saturday, monday, friday, endDate, configRev) + ); + + create table ConfigRevision ( + configRev number(10,0) not null, + notes varchar2(512 char), + processedTime timestamp, + zipFileLastModifiedTime timestamp, + primary key (configRev) + ); + + create table DbTest ( + id number(10,0) not null, + primary key (id) + ); + + create table FareAttributes ( + fareId varchar2(60 char) not null, + configRev number(10,0) not null, + currencyType varchar2(3 char), + paymentMethod varchar2(255 char), + price float, + transferDuration number(10,0), + transfers varchar2(255 char), + primary key (fareId, configRev) + ); + + create table FareRules ( + routeId varchar2(60 char) not null, + originId varchar2(60 char) not null, + fareId varchar2(60 char) not null, + destinationId varchar2(60 char) not null, + containsId varchar2(60 char) not null, + configRev number(10,0) not null, + primary key (routeId, originId, fareId, destinationId, containsId, configRev) + ); + + create table Frequencies ( + tripId varchar2(60 char) not null, + startTime number(10,0) not null, + configRev number(10,0) not null, + endTime number(10,0), + exactTimes number(1,0), + headwaySecs number(10,0), + primary key (tripId, startTime, configRev) + ); + + create table Headway ( + id number(19,0) not null, + average double precision, + coefficientOfVariation double precision, + configRev number(10,0), + creationTime timestamp, + firstDeparture timestamp, + headway double precision, + numVehicles number(10,0), + otherVehicleId varchar2(60 char), + routeId varchar2(60 char), + secondDeparture timestamp, + stopId varchar2(60 char), + tripId varchar2(60 char), + variance double precision, + vehicleId varchar2(60 char), + primary key (id) + ); + + create table HoldingTimes ( + id number(19,0) not null, + arrivalPredictionUsed number(1,0), + arrivalTime timestamp, + arrivalUsed number(1,0), + configRev number(10,0), + creationTime timestamp, + hasD1 number(1,0), + holdingTime timestamp, + numberPredictionsUsed number(10,0), + routeId varchar2(60 char), + stopId varchar2(60 char), + tripId varchar2(60 char), + vehicleId varchar2(60 char), + primary key (id) + ); + + create table Matches ( + vehicleId varchar2(60 char) not null, + avlTime timestamp not null, + atStop number(1,0), + blockId varchar2(60 char), + configRev number(10,0), + distanceAlongSegment float, + distanceAlongStopPath float, + segmentIndex number(10,0), + serviceId varchar2(255 char), + stopPathIndex number(10,0), + tripId varchar2(60 char), + primary key (vehicleId, avlTime) + ); + + create table MeasuredArrivalTimes ( + time timestamp not null, + stopId varchar2(60 char) not null, + directionId varchar2(60 char), + headsign varchar2(60 char), + routeId varchar2(60 char), + routeShortName varchar2(60 char), + primary key (time, stopId) + ); + + create table MonitoringEvents ( + type varchar2(40 char) not null, + time timestamp not null, + message varchar2(512 char), + triggered number(1,0), + value double precision, + primary key (type, time) + ); + + create table PredictionAccuracy ( + id number(19,0) not null, + affectedByWaitStop number(1,0), + arrivalDepartureTime timestamp, + directionId varchar2(60 char), + predictedTime timestamp, + predictionAccuracyMsecs number(10,0), + predictionReadTime timestamp, + predictionSource varchar2(60 char), + routeId varchar2(60 char), + routeShortName varchar2(60 char), + stopId varchar2(60 char), + tripId varchar2(60 char), + vehicleId varchar2(60 char), + primary key (id) + ); + + create table Predictions ( + id number(19,0) not null, + affectedByWaitStop number(1,0), + avlTime timestamp, + configRev number(10,0), + creationTime timestamp, + gtfsStopSeq number(10,0), + isArrival number(1,0), + predictionTime timestamp, + routeId varchar2(60 char), + schedBasedPred number(1,0), + stopId varchar2(60 char), + tripId varchar2(60 char), + vehicleId varchar2(60 char), + primary key (id) + ); + + create table Routes ( + id varchar2(60 char) not null, + configRev number(10,0) not null, + color varchar2(10 char), + description varchar2(1024 char), + maxLat double precision, + maxLon double precision, + minLat double precision, + minLon double precision, + hidden number(1,0), + longName varchar2(255 char), + maxDistance double precision, + name varchar2(255 char), + routeOrder number(10,0), + shortName varchar2(255 char), + textColor varchar2(10 char), + type varchar2(2 char), + primary key (id, configRev) + ); + + create table StopPathPredictions ( + id number(19,0) not null, + algorithm varchar2(255 char), + creationTime timestamp, + predictionTime double precision, + startTime number(10,0), + stopPathIndex number(10,0), + travelTime number(1,0), + tripId varchar2(60 char), + vehicleId varchar2(255 char), + primary key (id) + ); + + create table StopPath_locations ( + StopPath_tripPatternId varchar2(120 char) not null, + StopPath_stopPathId varchar2(120 char) not null, + StopPath_configRev number(10,0) not null, + lat double precision, + lon double precision, + locations_ORDER number(10,0) not null, + primary key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev, locations_ORDER) + ); + + create table StopPaths ( + tripPatternId varchar2(120 char) not null, + stopPathId varchar2(120 char) not null, + configRev number(10,0) not null, + breakTime number(10,0), + gtfsStopSeq number(10,0), + lastStopInTrip number(1,0), + layoverStop number(1,0), + maxDistance double precision, + maxSpeed double precision, + pathLength double precision, + routeId varchar2(60 char), + scheduleAdherenceStop number(1,0), + stopId varchar2(60 char), + waitStop number(1,0), + primary key (tripPatternId, stopPathId, configRev) + ); + + create table Stops ( + id varchar2(60 char) not null, + configRev number(10,0) not null, + code number(10,0), + hidden number(1,0), + layoverStop number(1,0), + lat double precision, + lon double precision, + name varchar2(255 char), + timepointStop number(1,0), + waitStop number(1,0), + primary key (id, configRev) + ); + + create table Transfers ( + toStopId varchar2(60 char) not null, + fromStopId varchar2(60 char) not null, + configRev number(10,0) not null, + minTransferTime number(10,0), + transferType varchar2(1 char), + primary key (toStopId, fromStopId, configRev) + ); + + create table TravelTimesForStopPaths ( + id number(10,0) not null, + configRev number(10,0), + daysOfWeekOverride number(5,0), + howSet varchar2(5 char), + stopPathId varchar2(120 char), + stopTimeMsec number(10,0), + travelTimeSegmentLength float, + travelTimesMsec long raw, + travelTimesRev number(10,0), + primary key (id) + ); + + create table TravelTimesForTrip_to_TravelTimesForPath_joinTable ( + TravelTimesForTrips_id number(10,0) not null, + travelTimesForStopPaths_id number(10,0) not null, + listIndex number(10,0) not null, + primary key (TravelTimesForTrips_id, listIndex) + ); + + create table TravelTimesForTrips ( + id number(10,0) not null, + configRev number(10,0), + travelTimesRev number(10,0), + tripCreatedForId varchar2(60 char), + tripPatternId varchar2(120 char), + primary key (id) + ); + + create table TripPattern_to_Path_joinTable ( + TripPatterns_id varchar2(120 char) not null, + TripPatterns_configRev number(10,0) not null, + stopPaths_tripPatternId varchar2(120 char) not null, + stopPaths_stopPathId varchar2(120 char) not null, + stopPaths_configRev number(10,0) not null, + listIndex number(10,0) not null, + primary key (TripPatterns_id, TripPatterns_configRev, listIndex) + ); + + create table TripPatterns ( + id varchar2(120 char) not null, + configRev number(10,0) not null, + directionId varchar2(60 char), + maxLat double precision, + maxLon double precision, + minLat double precision, + minLon double precision, + headsign varchar2(255 char), + routeId varchar2(60 char), + routeShortName varchar2(80 char), + shapeId varchar2(60 char), + primary key (id, configRev) + ); + + create table Trip_scheduledTimesList ( + Trip_tripId varchar2(60 char) not null, + Trip_startTime number(10,0) not null, + Trip_configRev number(10,0) not null, + arrivalTime number(10,0), + departureTime number(10,0), + scheduledTimesList_ORDER number(10,0) not null, + primary key (Trip_tripId, Trip_startTime, Trip_configRev, scheduledTimesList_ORDER) + ); + + create table Trips ( + tripId varchar2(60 char) not null, + startTime number(10,0) not null, + configRev number(10,0) not null, + blockId varchar2(60 char), + directionId varchar2(60 char), + endTime number(10,0), + exactTimesHeadway number(1,0), + headsign varchar2(255 char), + noSchedule number(1,0), + routeId varchar2(60 char), + routeShortName varchar2(60 char), + serviceId varchar2(60 char), + shapeId varchar2(60 char), + tripShortName varchar2(60 char), + travelTimes_id number(10,0), + tripPattern_id varchar2(120 char), + tripPattern_configRev number(10,0), + primary key (tripId, startTime, configRev) + ); + + create table VehicleConfigs ( + id varchar2(60 char) not null, + capacity number(10,0), + crushCapacity number(10,0), + description varchar2(255 char), + nonPassengerVehicle number(1,0), + trackerId varchar2(60 char), + type number(10,0), + primary key (id) + ); + + create table VehicleEvents ( + vehicleId varchar2(60 char) not null, + time timestamp not null, + eventType varchar2(60 char) not null, + avlTime timestamp, + becameUnpredictable number(1,0), + blockId varchar2(60 char), + description varchar2(500 char), + lat double precision, + lon double precision, + predictable number(1,0), + routeId varchar2(60 char), + routeShortName varchar2(60 char), + serviceId varchar2(60 char), + stopId varchar2(60 char), + supervisor varchar2(60 char), + tripId varchar2(60 char), + primary key (vehicleId, time, eventType) + ); + + create table VehicleStates ( + vehicleId varchar2(60 char) not null, + avlTime timestamp not null, + blockId varchar2(60 char), + isDelayed number(1,0), + isForSchedBasedPreds number(1,0), + isLayover number(1,0), + isPredictable number(1,0), + isWaitStop number(1,0), + routeId varchar2(60 char), + routeShortName varchar2(80 char), + schedAdh varchar2(50 char), + schedAdhMsec number(10,0), + schedAdhWithinBounds number(1,0), + tripId varchar2(60 char), + tripShortName varchar2(60 char), + primary key (vehicleId, avlTime) + ); + + create index ArrivalsDeparturesTimeIndex on ArrivalsDepartures (time); + + create index ArrivalsDeparturesRouteTimeIndex on ArrivalsDepartures (routeShortName, time); + + create index AvlReportsTimeIndex on AvlReports (time); + + create index HeadwayIndex on Headway (creationTime); + + create index HoldingTimeIndex on HoldingTimes (creationTime); + + create index AvlTimeIndex on Matches (avlTime); + + create index MeasuredArrivalTimesIndex on MeasuredArrivalTimes (time); + + create index MonitoringEventsTimeIndex on MonitoringEvents (time); + + create index PredictionAccuracyTimeIndex on PredictionAccuracy (arrivalDepartureTime); + + create index PredictionTimeIndex on Predictions (creationTime); + + create index StopPathPredictionTimeIndex on StopPathPredictions (tripId, stopPathIndex); + + create index TravelTimesRevIndex on TravelTimesForTrips (travelTimesRev); + + alter table TripPattern_to_Path_joinTable + add constraint UK_s0gaw8iv60vc17a5ltryqwg27 unique (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev); + + create index VehicleEventsTimeIndex on VehicleEvents (time); + + create index VehicleStateAvlTimeIndex on VehicleStates (avlTime); + + alter table Block_to_Trip_joinTable + add constraint FK_abaj8ke6oh4imbbgnaercsowo + foreign key (trips_tripId, trips_startTime, trips_configRev) + references Trips; + + alter table Block_to_Trip_joinTable + add constraint FK_1c1e1twdap19vq0xkav0amvm + foreign key (Blocks_serviceId, Blocks_configRev, Blocks_blockId) + references Blocks; + + alter table StopPath_locations + add constraint FK_sdjt3vtd3w0cl07p0doob6khi + foreign key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev) + references StopPaths; + + alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable + add constraint FK_hh5uepurijcqj0pyc6e3h5mqw + foreign key (travelTimesForStopPaths_id) + references TravelTimesForStopPaths; + + alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable + add constraint FK_9j1s8ewsmokqg4m35wrr29na7 + foreign key (TravelTimesForTrips_id) + references TravelTimesForTrips; + + alter table TripPattern_to_Path_joinTable + add constraint FK_s0gaw8iv60vc17a5ltryqwg27 + foreign key (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev) + references StopPaths; + + alter table TripPattern_to_Path_joinTable + add constraint FK_qsr8l6u1nelb5pt8rlnei08sy + foreign key (TripPatterns_id, TripPatterns_configRev) + references TripPatterns; + + alter table Trip_scheduledTimesList + add constraint FK_n5et0p70cwe1dwo4m6lq0k4h0 + foreign key (Trip_tripId, Trip_startTime, Trip_configRev) + references Trips; + + alter table Trips + add constraint FK_p1er53449kkfsca6mbnxkdyst + foreign key (travelTimes_id) + references TravelTimesForTrips; + + alter table Trips + add constraint FK_676npp7h4bxh8sjcnugnxt5wb + foreign key (tripPattern_id, tripPattern_configRev) + references TripPatterns; + + create sequence hibernate_sequence; diff --git a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql index e69de29bb..33cce163c 100644 --- a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql @@ -0,0 +1,561 @@ + + create table ActiveRevisions ( + id int4 not null, + configRev int4, + travelTimesRev int4, + primary key (id) + ); + + create table Agencies ( + configRev int4 not null, + agencyName varchar(60) not null, + agencyFareUrl varchar(255), + agencyId varchar(60), + agencyLang varchar(15), + agencyPhone varchar(15), + agencyTimezone varchar(40), + agencyUrl varchar(255), + maxLat float8, + maxLon float8, + minLat float8, + minLon float8, + primary key (configRev, agencyName) + ); + + create table ArrivalsDepartures ( + DTYPE varchar(31) not null, + vehicleId varchar(60) not null, + tripId varchar(60) not null, + time timestamp not null, + stopId varchar(60) not null, + isArrival boolean not null, + gtfsStopSeq int4 not null, + avlTime timestamp, + blockId varchar(60), + configRev int4, + directionId varchar(60), + freqStartTime timestamp, + routeId varchar(60), + routeShortName varchar(60), + scheduledTime timestamp, + serviceId varchar(60), + stopOrder int4, + stopPathIndex int4, + stopPathLength float4, + tripIndex int4, + primary key (vehicleId, tripId, time, stopId, isArrival, gtfsStopSeq) + ); + + create table AvlReports ( + vehicleId varchar(60) not null, + time timestamp not null, + assignmentId varchar(60), + assignmentType varchar(40), + driverId varchar(60), + field1Name varchar(60), + field1Value varchar(60), + heading float4, + licensePlate varchar(10), + lat float8, + lon float8, + passengerCount int4, + passengerFullness float4, + source varchar(10), + speed float4, + timeProcessed timestamp, + primary key (vehicleId, time) + ); + + create table Block_to_Trip_joinTable ( + Blocks_serviceId varchar(60) not null, + Blocks_configRev int4 not null, + Blocks_blockId varchar(60) not null, + trips_tripId varchar(60) not null, + trips_startTime int4 not null, + trips_configRev int4 not null, + listIndex int4 not null, + primary key (Blocks_serviceId, Blocks_configRev, Blocks_blockId, listIndex) + ); + + create table Blocks ( + serviceId varchar(60) not null, + configRev int4 not null, + blockId varchar(60) not null, + endTime int4, + routeIds bytea, + startTime int4, + primary key (serviceId, configRev, blockId) + ); + + create table CalendarDates ( + serviceId varchar(60) not null, + date date not null, + configRev int4 not null, + exceptionType varchar(2), + primary key (serviceId, date, configRev) + ); + + create table Calendars ( + wednesday boolean not null, + tuesday boolean not null, + thursday boolean not null, + sunday boolean not null, + startDate date not null, + serviceId varchar(60) not null, + saturday boolean not null, + monday boolean not null, + friday boolean not null, + endDate date not null, + configRev int4 not null, + primary key (wednesday, tuesday, thursday, sunday, startDate, serviceId, saturday, monday, friday, endDate, configRev) + ); + + create table ConfigRevision ( + configRev int4 not null, + notes varchar(512), + processedTime timestamp, + zipFileLastModifiedTime timestamp, + primary key (configRev) + ); + + create table DbTest ( + id int4 not null, + primary key (id) + ); + + create table FareAttributes ( + fareId varchar(60) not null, + configRev int4 not null, + currencyType varchar(3), + paymentMethod varchar(255), + price float4, + transferDuration int4, + transfers varchar(255), + primary key (fareId, configRev) + ); + + create table FareRules ( + routeId varchar(60) not null, + originId varchar(60) not null, + fareId varchar(60) not null, + destinationId varchar(60) not null, + containsId varchar(60) not null, + configRev int4 not null, + primary key (routeId, originId, fareId, destinationId, containsId, configRev) + ); + + create table Frequencies ( + tripId varchar(60) not null, + startTime int4 not null, + configRev int4 not null, + endTime int4, + exactTimes boolean, + headwaySecs int4, + primary key (tripId, startTime, configRev) + ); + + create table Headway ( + id int8 not null, + average float8, + coefficientOfVariation float8, + configRev int4, + creationTime timestamp, + firstDeparture timestamp, + headway float8, + numVehicles int4, + otherVehicleId varchar(60), + routeId varchar(60), + secondDeparture timestamp, + stopId varchar(60), + tripId varchar(60), + variance float8, + vehicleId varchar(60), + primary key (id) + ); + + create table HoldingTimes ( + id int8 not null, + arrivalPredictionUsed boolean, + arrivalTime timestamp, + arrivalUsed boolean, + configRev int4, + creationTime timestamp, + hasD1 boolean, + holdingTime timestamp, + numberPredictionsUsed int4, + routeId varchar(60), + stopId varchar(60), + tripId varchar(60), + vehicleId varchar(60), + primary key (id) + ); + + create table Matches ( + vehicleId varchar(60) not null, + avlTime timestamp not null, + atStop boolean, + blockId varchar(60), + configRev int4, + distanceAlongSegment float4, + distanceAlongStopPath float4, + segmentIndex int4, + serviceId varchar(255), + stopPathIndex int4, + tripId varchar(60), + primary key (vehicleId, avlTime) + ); + + create table MeasuredArrivalTimes ( + time timestamp not null, + stopId varchar(60) not null, + directionId varchar(60), + headsign varchar(60), + routeId varchar(60), + routeShortName varchar(60), + primary key (time, stopId) + ); + + create table MonitoringEvents ( + type varchar(40) not null, + time timestamp not null, + message varchar(512), + triggered boolean, + value float8, + primary key (type, time) + ); + + create table PredictionAccuracy ( + id int8 not null, + affectedByWaitStop boolean, + arrivalDepartureTime timestamp, + directionId varchar(60), + predictedTime timestamp, + predictionAccuracyMsecs int4, + predictionReadTime timestamp, + predictionSource varchar(60), + routeId varchar(60), + routeShortName varchar(60), + stopId varchar(60), + tripId varchar(60), + vehicleId varchar(60), + primary key (id) + ); + + create table Predictions ( + id int8 not null, + affectedByWaitStop boolean, + avlTime timestamp, + configRev int4, + creationTime timestamp, + gtfsStopSeq int4, + isArrival boolean, + predictionTime timestamp, + routeId varchar(60), + schedBasedPred boolean, + stopId varchar(60), + tripId varchar(60), + vehicleId varchar(60), + primary key (id) + ); + + create table Routes ( + id varchar(60) not null, + configRev int4 not null, + color varchar(10), + description varchar(1024), + maxLat float8, + maxLon float8, + minLat float8, + minLon float8, + hidden boolean, + longName varchar(255), + maxDistance float8, + name varchar(255), + routeOrder int4, + shortName varchar(255), + textColor varchar(10), + type varchar(2), + primary key (id, configRev) + ); + + create table StopPathPredictions ( + id int8 not null, + algorithm varchar(255), + creationTime timestamp, + predictionTime float8, + startTime int4, + stopPathIndex int4, + travelTime boolean, + tripId varchar(60), + vehicleId varchar(255), + primary key (id) + ); + + create table StopPath_locations ( + StopPath_tripPatternId varchar(120) not null, + StopPath_stopPathId varchar(120) not null, + StopPath_configRev int4 not null, + lat float8, + lon float8, + locations_ORDER int4 not null, + primary key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev, locations_ORDER) + ); + + create table StopPaths ( + tripPatternId varchar(120) not null, + stopPathId varchar(120) not null, + configRev int4 not null, + breakTime int4, + gtfsStopSeq int4, + lastStopInTrip boolean, + layoverStop boolean, + maxDistance float8, + maxSpeed float8, + pathLength float8, + routeId varchar(60), + scheduleAdherenceStop boolean, + stopId varchar(60), + waitStop boolean, + primary key (tripPatternId, stopPathId, configRev) + ); + + create table Stops ( + id varchar(60) not null, + configRev int4 not null, + code int4, + hidden boolean, + layoverStop boolean, + lat float8, + lon float8, + name varchar(255), + timepointStop boolean, + waitStop boolean, + primary key (id, configRev) + ); + + create table Transfers ( + toStopId varchar(60) not null, + fromStopId varchar(60) not null, + configRev int4 not null, + minTransferTime int4, + transferType varchar(1), + primary key (toStopId, fromStopId, configRev) + ); + + create table TravelTimesForStopPaths ( + id int4 not null, + configRev int4, + daysOfWeekOverride int2, + howSet varchar(5), + stopPathId varchar(120), + stopTimeMsec int4, + travelTimeSegmentLength float4, + travelTimesMsec bytea, + travelTimesRev int4, + primary key (id) + ); + + create table TravelTimesForTrip_to_TravelTimesForPath_joinTable ( + TravelTimesForTrips_id int4 not null, + travelTimesForStopPaths_id int4 not null, + listIndex int4 not null, + primary key (TravelTimesForTrips_id, listIndex) + ); + + create table TravelTimesForTrips ( + id int4 not null, + configRev int4, + travelTimesRev int4, + tripCreatedForId varchar(60), + tripPatternId varchar(120), + primary key (id) + ); + + create table TripPattern_to_Path_joinTable ( + TripPatterns_id varchar(120) not null, + TripPatterns_configRev int4 not null, + stopPaths_tripPatternId varchar(120) not null, + stopPaths_stopPathId varchar(120) not null, + stopPaths_configRev int4 not null, + listIndex int4 not null, + primary key (TripPatterns_id, TripPatterns_configRev, listIndex) + ); + + create table TripPatterns ( + id varchar(120) not null, + configRev int4 not null, + directionId varchar(60), + maxLat float8, + maxLon float8, + minLat float8, + minLon float8, + headsign varchar(255), + routeId varchar(60), + routeShortName varchar(80), + shapeId varchar(60), + primary key (id, configRev) + ); + + create table Trip_scheduledTimesList ( + Trip_tripId varchar(60) not null, + Trip_startTime int4 not null, + Trip_configRev int4 not null, + arrivalTime int4, + departureTime int4, + scheduledTimesList_ORDER int4 not null, + primary key (Trip_tripId, Trip_startTime, Trip_configRev, scheduledTimesList_ORDER) + ); + + create table Trips ( + tripId varchar(60) not null, + startTime int4 not null, + configRev int4 not null, + blockId varchar(60), + directionId varchar(60), + endTime int4, + exactTimesHeadway boolean, + headsign varchar(255), + noSchedule boolean, + routeId varchar(60), + routeShortName varchar(60), + serviceId varchar(60), + shapeId varchar(60), + tripShortName varchar(60), + travelTimes_id int4, + tripPattern_id varchar(120), + tripPattern_configRev int4, + primary key (tripId, startTime, configRev) + ); + + create table VehicleConfigs ( + id varchar(60) not null, + capacity int4, + crushCapacity int4, + description varchar(255), + nonPassengerVehicle boolean, + trackerId varchar(60), + type int4, + primary key (id) + ); + + create table VehicleEvents ( + vehicleId varchar(60) not null, + time timestamp not null, + eventType varchar(60) not null, + avlTime timestamp, + becameUnpredictable boolean, + blockId varchar(60), + description varchar(500), + lat float8, + lon float8, + predictable boolean, + routeId varchar(60), + routeShortName varchar(60), + serviceId varchar(60), + stopId varchar(60), + supervisor varchar(60), + tripId varchar(60), + primary key (vehicleId, time, eventType) + ); + + create table VehicleStates ( + vehicleId varchar(60) not null, + avlTime timestamp not null, + blockId varchar(60), + isDelayed boolean, + isForSchedBasedPreds boolean, + isLayover boolean, + isPredictable boolean, + isWaitStop boolean, + routeId varchar(60), + routeShortName varchar(80), + schedAdh varchar(50), + schedAdhMsec int4, + schedAdhWithinBounds boolean, + tripId varchar(60), + tripShortName varchar(60), + primary key (vehicleId, avlTime) + ); + + create index ArrivalsDeparturesTimeIndex on ArrivalsDepartures (time); + + create index ArrivalsDeparturesRouteTimeIndex on ArrivalsDepartures (routeShortName, time); + + create index AvlReportsTimeIndex on AvlReports (time); + + create index HeadwayIndex on Headway (creationTime); + + create index HoldingTimeIndex on HoldingTimes (creationTime); + + create index AvlTimeIndex on Matches (avlTime); + + create index MeasuredArrivalTimesIndex on MeasuredArrivalTimes (time); + + create index MonitoringEventsTimeIndex on MonitoringEvents (time); + + create index PredictionAccuracyTimeIndex on PredictionAccuracy (arrivalDepartureTime); + + create index PredictionTimeIndex on Predictions (creationTime); + + create index StopPathPredictionTimeIndex on StopPathPredictions (tripId, stopPathIndex); + + create index TravelTimesRevIndex on TravelTimesForTrips (travelTimesRev); + + alter table TripPattern_to_Path_joinTable + add constraint UK_s0gaw8iv60vc17a5ltryqwg27 unique (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev); + + create index VehicleEventsTimeIndex on VehicleEvents (time); + + create index VehicleStateAvlTimeIndex on VehicleStates (avlTime); + + alter table Block_to_Trip_joinTable + add constraint FK_abaj8ke6oh4imbbgnaercsowo + foreign key (trips_tripId, trips_startTime, trips_configRev) + references Trips; + + alter table Block_to_Trip_joinTable + add constraint FK_1c1e1twdap19vq0xkav0amvm + foreign key (Blocks_serviceId, Blocks_configRev, Blocks_blockId) + references Blocks; + + alter table StopPath_locations + add constraint FK_sdjt3vtd3w0cl07p0doob6khi + foreign key (StopPath_tripPatternId, StopPath_stopPathId, StopPath_configRev) + references StopPaths; + + alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable + add constraint FK_hh5uepurijcqj0pyc6e3h5mqw + foreign key (travelTimesForStopPaths_id) + references TravelTimesForStopPaths; + + alter table TravelTimesForTrip_to_TravelTimesForPath_joinTable + add constraint FK_9j1s8ewsmokqg4m35wrr29na7 + foreign key (TravelTimesForTrips_id) + references TravelTimesForTrips; + + alter table TripPattern_to_Path_joinTable + add constraint FK_s0gaw8iv60vc17a5ltryqwg27 + foreign key (stopPaths_tripPatternId, stopPaths_stopPathId, stopPaths_configRev) + references StopPaths; + + alter table TripPattern_to_Path_joinTable + add constraint FK_qsr8l6u1nelb5pt8rlnei08sy + foreign key (TripPatterns_id, TripPatterns_configRev) + references TripPatterns; + + alter table Trip_scheduledTimesList + add constraint FK_n5et0p70cwe1dwo4m6lq0k4h0 + foreign key (Trip_tripId, Trip_startTime, Trip_configRev) + references Trips; + + alter table Trips + add constraint FK_p1er53449kkfsca6mbnxkdyst + foreign key (travelTimes_id) + references TravelTimesForTrips; + + alter table Trips + add constraint FK_676npp7h4bxh8sjcnugnxt5wb + foreign key (tripPattern_id, tripPattern_configRev) + references TripPatterns; + + create sequence hibernate_sequence; From 7efdbf32630b5584c1ac9cfc2d50f1be71da0bc6 Mon Sep 17 00:00:00 2001 From: scrudden Date: Sat, 12 Jan 2019 18:07:13 +0000 Subject: [PATCH 4/4] Add correct SQL files with latest database create scripts. --- ..._structs.sql => ddl_mysql_org_transitclock_db_structs.sql} | 4 ++-- ...ructs.sql => ddl_mysql_org_transitclock_db_webstructs.sql} | 0 ...structs.sql => ddl_oracle_org_transitclock_db_structs.sql} | 4 ++-- ...ucts.sql => ddl_oracle_org_transitclock_db_webstructs.sql} | 0 ...ructs.sql => ddl_postgres_org_transitclock_db_structs.sql} | 4 ++-- ...ts.sql => ddl_postgres_org_transitclock_db_webstructs.sql} | 0 6 files changed, 6 insertions(+), 6 deletions(-) rename transitclock/src/main/resources/{ddl_mysql_org_transitime_db_structs.sql => ddl_mysql_org_transitclock_db_structs.sql} (99%) rename transitclock/src/main/resources/{ddl_mysql_org_transitime_db_webstructs.sql => ddl_mysql_org_transitclock_db_webstructs.sql} (100%) rename transitclock/src/main/resources/{ddl_oracle_org_transitime_db_structs.sql => ddl_oracle_org_transitclock_db_structs.sql} (99%) rename transitclock/src/main/resources/{ddl_oracle_org_transitime_db_webstructs.sql => ddl_oracle_org_transitclock_db_webstructs.sql} (100%) rename transitclock/src/main/resources/{ddl_postgres_org_transitime_db_structs.sql => ddl_postgres_org_transitclock_db_structs.sql} (99%) rename transitclock/src/main/resources/{ddl_postgres_org_transitime_db_webstructs.sql => ddl_postgres_org_transitclock_db_webstructs.sql} (100%) diff --git a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_mysql_org_transitclock_db_structs.sql similarity index 99% rename from transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql rename to transitclock/src/main/resources/ddl_mysql_org_transitclock_db_structs.sql index 819223bd1..2476abca0 100644 --- a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_mysql_org_transitclock_db_structs.sql @@ -9,8 +9,8 @@ create table Agencies ( configRev integer not null, agencyName varchar(60) not null, + agencyId varchar(60) not null, agencyFareUrl varchar(255), - agencyId varchar(60), agencyLang varchar(15), agencyPhone varchar(15), agencyTimezone varchar(40), @@ -19,7 +19,7 @@ maxLon double precision, minLat double precision, minLon double precision, - primary key (configRev, agencyName) + primary key (configRev, agencyName, agencyId) ); create table ArrivalsDepartures ( diff --git a/transitclock/src/main/resources/ddl_mysql_org_transitime_db_webstructs.sql b/transitclock/src/main/resources/ddl_mysql_org_transitclock_db_webstructs.sql similarity index 100% rename from transitclock/src/main/resources/ddl_mysql_org_transitime_db_webstructs.sql rename to transitclock/src/main/resources/ddl_mysql_org_transitclock_db_webstructs.sql diff --git a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_oracle_org_transitclock_db_structs.sql similarity index 99% rename from transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql rename to transitclock/src/main/resources/ddl_oracle_org_transitclock_db_structs.sql index 6f0c49cc4..fb7af706d 100644 --- a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_oracle_org_transitclock_db_structs.sql @@ -9,8 +9,8 @@ create table Agencies ( configRev number(10,0) not null, agencyName varchar2(60 char) not null, + agencyId varchar2(60 char) not null, agencyFareUrl varchar2(255 char), - agencyId varchar2(60 char), agencyLang varchar2(15 char), agencyPhone varchar2(15 char), agencyTimezone varchar2(40 char), @@ -19,7 +19,7 @@ maxLon double precision, minLat double precision, minLon double precision, - primary key (configRev, agencyName) + primary key (configRev, agencyName, agencyId) ); create table ArrivalsDepartures ( diff --git a/transitclock/src/main/resources/ddl_oracle_org_transitime_db_webstructs.sql b/transitclock/src/main/resources/ddl_oracle_org_transitclock_db_webstructs.sql similarity index 100% rename from transitclock/src/main/resources/ddl_oracle_org_transitime_db_webstructs.sql rename to transitclock/src/main/resources/ddl_oracle_org_transitclock_db_webstructs.sql diff --git a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql b/transitclock/src/main/resources/ddl_postgres_org_transitclock_db_structs.sql similarity index 99% rename from transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql rename to transitclock/src/main/resources/ddl_postgres_org_transitclock_db_structs.sql index 33cce163c..838c52147 100644 --- a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_structs.sql +++ b/transitclock/src/main/resources/ddl_postgres_org_transitclock_db_structs.sql @@ -9,8 +9,8 @@ create table Agencies ( configRev int4 not null, agencyName varchar(60) not null, + agencyId varchar(60) not null, agencyFareUrl varchar(255), - agencyId varchar(60), agencyLang varchar(15), agencyPhone varchar(15), agencyTimezone varchar(40), @@ -19,7 +19,7 @@ maxLon float8, minLat float8, minLon float8, - primary key (configRev, agencyName) + primary key (configRev, agencyName, agencyId) ); create table ArrivalsDepartures ( diff --git a/transitclock/src/main/resources/ddl_postgres_org_transitime_db_webstructs.sql b/transitclock/src/main/resources/ddl_postgres_org_transitclock_db_webstructs.sql similarity index 100% rename from transitclock/src/main/resources/ddl_postgres_org_transitime_db_webstructs.sql rename to transitclock/src/main/resources/ddl_postgres_org_transitclock_db_webstructs.sql