forked from entur/tiamat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add quay publicCode & streetAddress to stop_place_newest_version
- Loading branch information
1 parent
597b48b
commit e2d81c0
Showing
1 changed file
with
18 additions
and
4 deletions.
There are no files selected for viewing
22 changes: 18 additions & 4 deletions
22
src/main/resources/db/migration/R__view_for_newest_stop_place_versions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
create or replace view stop_place_newest_version as | ||
select distinct on (netex_id) * | ||
from stop_place | ||
order by netex_id, version desc; | ||
DROP VIEW IF EXISTS stop_place_newest_version; | ||
|
||
CREATE VIEW stop_place_newest_version AS | ||
SELECT DISTINCT ON (sp.netex_id) | ||
sp.*, | ||
quay.public_code AS quay_public_code, | ||
address_value.items as street_address | ||
|
||
FROM stop_place AS sp | ||
|
||
INNER JOIN stop_place_quays AS spq ON sp.id = spq.stop_place_id | ||
INNER JOIN quay ON spq.quays_id = quay.id | ||
|
||
LEFT JOIN stop_place_key_values AS spkv ON | ||
sp.id = spkv.stop_place_id AND spkv.key_values_key = 'streetAddress' | ||
LEFT JOIN value_items AS address_value ON spkv.key_values_id = address_value.value_id | ||
|
||
ORDER BY netex_id ASC, version DESC | ||
|