chore: initial commit
This commit is contained in:
parent
65af79034f
commit
3851946f4b
|
@ -0,0 +1,8 @@
|
|||
* establisch a SSH tunnel like this:\
|
||||
```
|
||||
ssh -L <local port>:<local host address>:<remote port> -p <SSH port of remote SSH server> <user at remote server>@<host name of remote server>
|
||||
```
|
||||
* connect to database using pgsl CLI tool like this:\
|
||||
```
|
||||
psql -h localhost -p 5432 -U <user> -d <db>
|
||||
```
|
|
@ -0,0 +1,4 @@
|
|||
* create `entities` table
|
||||
```
|
||||
./script/create-entities-table.sh
|
||||
```
|
|
@ -0,0 +1,3 @@
|
|||
* connect to database like [this](./doc/connect2db.md)
|
||||
|
||||
* create initial database like [this](./doc/create-db.md)
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
echo "Started..."
|
||||
#Started...
|
||||
DB_NAME="osm_poi"
|
||||
DB_USER="osm_poi"
|
||||
HIS_HOST="zvbn-his.de"
|
||||
HIS_USER="zvbn_steckbrief"
|
||||
HIS_DB="his"
|
||||
#
|
||||
#import P+R and B+R data from HIS into tabelle infra.brpr
|
||||
psql -d $DB_NAME -U $DB_USER -c "DELETE FROM infra.brpr;"
|
||||
psql -h $HIS_HOST -U $HIS_USER -d $HIS_DB -f /home/${DB_USER}/sql/poi/export_pr_br_02.sql| psql -U $DB_USER -d $DB_NAME -c "COPY infra.brpr(id,kat,name,strasse,plz,gemeinde_his,gemeinde,landkreis,x_gk3,y_gk3,anlage_erkennbar,stellplaetze,emob,betreiber,linien) FROM STDIN WITH DELIMITER AS '|' CSV ;"
|
||||
#
|
||||
psql -U $DB_USER -f /home/${DB_USER}/sql/poi/vw_poi_fahrplaner_17.sql -d $DB_NAME
|
||||
psql -U $DB_USER -c 'DROP VIEW IF EXISTS public.vw_export_poi;' -d $DB_NAME
|
||||
psql -U $DB_USER -c 'DROP TABLE IF EXISTS public.tbl_poi_fahrplaner;' -d $DB_NAME
|
||||
psql -U $DB_USER -c 'CREATE TABLE tbl_poi_fahrplaner AS SELECT * FROM vw_poi_fahrplaner;' -d $DB_NAME
|
||||
#TODO What is the reason for the following instruction?
|
||||
psql -U $DB_USER -c 'CREATE INDEX ind_gemeinde ON public.tbl_poi_fahrplaner USING btree (gemeinde)' -d $DB_NAME
|
||||
#
|
||||
#create VIEW public.vw_export_poi for the POI export(OSM, BR, PR, VVK)
|
||||
psql -U $DB_USER -d $DB_NAME -f /home/${DB_USER}/sql/poi/gesamtexport_poi_br_pr_vv_10.sql
|
||||
#
|
||||
#create exports (second call is for Leaflet map view which uses different separators)
|
||||
psql -U $DB_USER -d $DB_NAME -c "COPY (SELECT * FROM public.vw_export_poi) TO STDOUT WITH DELIMITER AS ';' CSV HEADER NULL '' QUOTE '\"';" -o /home/${DB_USER}/osm_poi/osm_poi.csv
|
||||
#TODO Required? psql -U $DB_USER -d $DB_NAME -c "COPY (SELECT * FROM public.vw_export_poi) TO STDOUT WITH DELIMITER AS '^' CSV HEADER NULL '' QUOTE '\"' FORCE QUOTE website,oeffnungszeiten;" -o /home/${DB_USER}/osm_poi/osm_poi_ll.csv
|
||||
#
|
||||
#copy files from tmp folder to server main folger
|
||||
cp /home/${DB_USER}/osm_poi/osm_poi.csv /var/www/poi_utf8_demo.csv
|
||||
#TODO Required? cp /home/${DB_USER}/osm_poi/osm_poi_ll.csv /var/www/osm_poi_ll_utf8.csv
|
||||
#
|
||||
echo "Done."
|
||||
#done.
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
echo "Started..."
|
||||
#Started...
|
||||
DB_NAME="todo"
|
||||
DB_USER="todo"
|
||||
#
|
||||
psql -h localhost -p 5432 -U $DB_USER -f ./sql/create-relation_roles-table.sql -d $DB_NAME
|
||||
#
|
||||
echo "Done."
|
||||
#Done.
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
echo "Started..."
|
||||
#Started...
|
||||
DB_NAME="todo"
|
||||
DB_USER="todo"
|
||||
#
|
||||
psql -h localhost -p 5432 -U $DB_USER -f ./sql/create-relations-table.sql -d $DB_NAME
|
||||
#
|
||||
echo "Done."
|
||||
#Done.
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
DROP TABLE IF EXISTS entities;
|
||||
---
|
||||
CREATE TABLE IF NOT EXISTS entities(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL);
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
DROP TABLE IF EXISTS relation_roles;
|
||||
---
|
||||
CREATE TABLE IF NOT EXISTS relation_roles(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL);
|
||||
---
|
||||
DELETE FROM relation_roles;
|
||||
INSERT INTO relation_roles (name)
|
||||
VALUES
|
||||
('supplier'),
|
||||
('customer')
|
||||
RETURNING *;
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
DROP TABLE IF EXISTS relations;
|
||||
---
|
||||
CREATE TABLE IF NOT EXISTS relations(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
relation_role BIGINT NOT NULL,
|
||||
from_entity BIGINT NOT NULL,
|
||||
to_entity BIGINT NOT NULL,
|
||||
FOREIGN KEY(relation_role) REFERENCES relation_roles(id),
|
||||
FOREIGN KEY(to_entity) REFERENCES entities(id),
|
||||
FOREIGN KEY(from_entity) REFERENCES entities(id));
|
Loading…
Reference in New Issue