Unverified Commit 519e9987 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

journeys_str: timestamps and time ranges are integers

parent d743252a
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -3763,6 +3763,62 @@ qq{select distinct checkout_station_id from in_transit where backend_id = 0;}
		);
		print $v72_migration_fyi;
	},

	# v72 -> v73
	# export timestamps as integers, not strings
	sub {
		my ($db) = @_;
		$db->query(
			qq{
				drop view journeys_str;
				create view journeys_str as select
					journeys.id as journey_id, user_id,
					backend.iris as is_iris, backend.hafas as is_hafas,
					backend.efa as is_efa, backend.dbris as is_dbris,
					backend.motis as is_motis,
					backend.name as backend_name, journeys.backend_id as backend_id,
					train_type, train_line, train_no, train_id,
					distance_beeline, distance_route, distance_polyline,
					extract(epoch from checkin_time) :: int8 as checkin_ts,
					extract(epoch from sched_departure) :: int8 as sched_dep_ts,
					extract(epoch from real_departure) :: int8 as real_dep_ts,
					extract(epoch from real_departure - sched_departure) :: int8 as delay_dep,
					checkin_station_id as dep_eva,
					dep_station.ds100 as dep_ds100,
					dep_station.name as dep_name,
					dep_station.lat as dep_lat,
					dep_station.lon as dep_lon,
					dep_station_external_id.external_id as dep_external_id,
					extract(epoch from checkout_time) :: int8 as checkout_ts,
					extract(epoch from sched_arrival) :: int8 as sched_arr_ts,
					extract(epoch from real_arrival) :: int8 as real_arr_ts,
					extract(epoch from real_arrival - sched_arrival) :: int8 as delay_arr,
					checkout_station_id as arr_eva,
					arr_station.ds100 as arr_ds100,
					arr_station.name as arr_name,
					arr_station.lat as arr_lat,
					arr_station.lon as arr_lon,
					arr_station_external_id.external_id as arr_external_id,
					extract(epoch from sched_arrival - sched_departure) :: int8 as sched_duration,
					extract(epoch from real_arrival - real_departure) :: int8 as rt_duration,
					polylines.polyline as polyline,
					visibility,
					coalesce(visibility, users.public_level & 127) as effective_visibility,
					cancelled, edited, route, messages, user_data,
					dep_platform, arr_platform
					from journeys
					left join polylines on polylines.id = polyline_id
					left join users on users.id = user_id
					left join stations as dep_station on checkin_station_id = dep_station.eva and journeys.backend_id = dep_station.source
					left join stations as arr_station on checkout_station_id = arr_station.eva and journeys.backend_id = arr_station.source
					left join stations_external_ids as dep_station_external_id on checkin_station_id = dep_station_external_id.eva and journeys.backend_id = dep_station_external_id.backend_id
					left join stations_external_ids as arr_station_external_id on checkout_station_id = arr_station_external_id.eva and journeys.backend_id = arr_station_external_id.backend_id
					left join backends as backend on journeys.backend_id = backend.id
					;
				update schema_version set version = 73;
			}
		);
	},
);

sub sync_dbdb {