diff --git a/db/sql/scripts/bus_stop.sql b/db/sql/scripts/bus_stop.sql index d30707a..1dbc9d6 100644 --- a/db/sql/scripts/bus_stop.sql +++ b/db/sql/scripts/bus_stop.sql @@ -102,4 +102,4 @@ SELECT foo.id, WHERE (lk.name = ANY (ARRAY['Braunschweig','Salzgitter','Wolfsburg','Gifhorn','Landkreis Goslar','Landkreis Helmstedt','Landkreis Peine','Landkreis Wolfenbüttel'])) AND foo.name IS NOT NULL AND foo.kategorie <> 999 ORDER BY lk.name, gem.name, foo.kategorie, foo.name; -CREATE TABLE :schema.tbl_bus_stop AS SELECT * FROM :schema.vw_bus_stop; +CREATE TABLE IF NOT EXISTS :schema.tbl_bus_stop AS SELECT * FROM :schema.vw_bus_stop; diff --git a/db/sql/scripts/poi.sql b/db/sql/scripts/poi.sql index 10e5887..7dc3c46 100644 --- a/db/sql/scripts/poi.sql +++ b/db/sql/scripts/poi.sql @@ -5,7 +5,7 @@ SET search_path to :schema, public; DROP TABLE IF EXISTS :schema.tbl_poi; DROP VIEW IF EXISTS :schema.vw_poi; -CREATE OR REPLACE VIEW :schema.vw_poi AS +CREATE OR REPLACE VIEW IF NOT EXISTS :schema.vw_poi AS SELECT foo.id, foo.osm_id, foo.name, foo.kategorie, lk.name as landkreis, CASE WHEN gem.name IS NULL THEN lk.name ELSE gem.name END as gemeinde, @@ -271,4 +271,4 @@ LEFT JOIN vw_municipalities gem ON st_contains(gem.way, st_transform(st_geomfrom WHERE (lk.name = ANY (ARRAY['Braunschweig','Salzgitter','Wolfsburg','Gifhorn','Landkreis Goslar','Landkreis Helmstedt','Landkreis Peine','Landkreis Wolfenbüttel'])) AND foo.name IS NOT NULL AND foo.kategorie <> 999 ORDER BY lk.name, gem.name, foo.kategorie, foo.name; -CREATE TABLE :schema.tbl_poi AS SELECT * FROM :schema.vw_poi; +CREATE TABLE IF NOT EXISTS :schema.tbl_poi AS SELECT * FROM :schema.vw_poi; diff --git a/db/sql/scripts/railway.sql b/db/sql/scripts/railway.sql index e3fe7e1..3744bb3 100644 --- a/db/sql/scripts/railway.sql +++ b/db/sql/scripts/railway.sql @@ -5,7 +5,7 @@ SET search_path to :schema, public; DROP TABLE IF EXISTS :schema.tbl_railway; DROP VIEW IF EXISTS :schema.vw_railway; -CREATE OR REPLACE VIEW :schema.vw_railway AS +CREATE OR REPLACE VIEW IF NOT EXISTS :schema.vw_railway AS SELECT foo.id, foo.osm_id, foo.railway, @@ -88,4 +88,4 @@ SELECT foo.id, WHERE (lk.name = ANY (ARRAY['Braunschweig','Salzgitter','Wolfsburg','Gifhorn','Landkreis Goslar','Landkreis Helmstedt','Landkreis Peine','Landkreis Wolfenbüttel'])) AND foo.name IS NOT NULL ORDER BY lk.name, gem.name, foo.name; -CREATE TABLE :schema.tbl_railway AS SELECT * FROM :schema.vw_railway; +CREATE TABLE IF NOT EXISTS :schema.tbl_railway AS SELECT * FROM :schema.vw_railway; diff --git a/db/sql/scripts/vw_counties.sql b/db/sql/scripts/vw_counties.sql index 6789268..6c24674 100644 --- a/db/sql/scripts/vw_counties.sql +++ b/db/sql/scripts/vw_counties.sql @@ -2,9 +2,9 @@ CREATE SCHEMA IF NOT EXISTS :schema; SET search_path to :schema, public; -DROP VIEW :schema.vw_counties CASCADE; +DROP VIEW IF EXISTS :schema.vw_counties CASCADE; -CREATE OR REPLACE VIEW :schema.vw_counties AS +CREATE OR REPLACE VIEW IF NOT EXISTS :schema.vw_counties AS SELECT planet_osm_polygon.osm_id, planet_osm_polygon.name, planet_osm_polygon.boundary, diff --git a/db/sql/scripts/vw_export_poi.sql b/db/sql/scripts/vw_export_poi.sql index 8bea984..149b4e3 100644 --- a/db/sql/scripts/vw_export_poi.sql +++ b/db/sql/scripts/vw_export_poi.sql @@ -2,7 +2,7 @@ CREATE SCHEMA IF NOT EXISTS :schema; SET search_path to :schema, public; -CREATE OR REPLACE VIEW :schema.vw_export_poi AS +CREATE OR REPLACE VIEW IF NOT EXISTS :schema.vw_export_poi AS SELECT foo.id, foo.kat, tl.deutsch as kat_de, tl.english as kat_en, foo.kat_sub as kat_sub_de, foo.kat_sub as kat_sub_en, foo.name, foo.adr_street AS strasse, foo.plz, foo.gemeinde, foo.landkreis, diff --git a/db/sql/scripts/vw_municipalities.sql b/db/sql/scripts/vw_municipalities.sql index 964eacd..1afd13d 100644 --- a/db/sql/scripts/vw_municipalities.sql +++ b/db/sql/scripts/vw_municipalities.sql @@ -2,7 +2,7 @@ CREATE SCHEMA IF NOT EXISTS :schema; SET search_path to :schema, public; -DROP VIEW :schema.vw_municipalities CASCADE; +DROP VIEW IF EXISTS :schema.vw_municipalities CASCADE; CREATE OR REPLACE VIEW :schema.vw_municipalities AS SELECT planet_osm_polygon.osm_id,