From 1ba1fe34800a8685161f93e444f59190c6971b91 Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Tue, 25 Apr 2023 21:36:30 +0200 Subject: [PATCH] feat: adjust scripts --- script/create-relation_roles-table.sh | 11 --------- script/create-relations-table.sh | 0 sql/create-entities-table.sql | 8 ++++--- sql/create-relation_roles-table.sql | 13 ----------- sql/create-relations-table.sql | 33 ++++++++++++++------------- 5 files changed, 22 insertions(+), 43 deletions(-) delete mode 100644 script/create-relation_roles-table.sh mode change 100644 => 100755 script/create-relations-table.sh delete mode 100644 sql/create-relation_roles-table.sql diff --git a/script/create-relation_roles-table.sh b/script/create-relation_roles-table.sh deleted file mode 100644 index 838ed52..0000000 --- a/script/create-relation_roles-table.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/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. diff --git a/script/create-relations-table.sh b/script/create-relations-table.sh old mode 100644 new mode 100755 diff --git a/sql/create-entities-table.sql b/sql/create-entities-table.sql index debcd14..6244033 100644 --- a/sql/create-entities-table.sql +++ b/sql/create-entities-table.sql @@ -1,8 +1,6 @@ --- DROP TABLE IF EXISTS relations; --- -DROP TABLE IF EXISTS relation_roles; ---- DROP TABLE IF EXISTS entities; --- CREATE TABLE IF NOT EXISTS entities( @@ -19,7 +17,11 @@ VALUES ('Hostsharing eG',53.6388387,10.0148720), ('WEtell GmbH',48.0143619,7.8450213), ('WTF Kooperative eG',53.5836365,10.0153690), +('Software Ingenieur Begerad',52.2659474, 10.4394900), ('GLS Gemeinschaftsbank eG',51.4708953,7.2195074), ('Fairphone', 52.3900606,4.8890757), -('dieUmweltDruckerei GmbH',52.3741017,9.7454469) +('dieUmweltDruckerei GmbH',52.3741017,9.7454469), +('Reka',52.1625908,10.2982074), +('Hof Morgentau',52.2254150,10.4556969), +('Der kleine Heideladen',52.2651152, 10.43836880) RETURNING *; diff --git a/sql/create-relation_roles-table.sql b/sql/create-relation_roles-table.sql deleted file mode 100644 index 4285ffc..0000000 --- a/sql/create-relation_roles-table.sql +++ /dev/null @@ -1,13 +0,0 @@ ---- -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 *; diff --git a/sql/create-relations-table.sql b/sql/create-relations-table.sql index ffa9923..2bf6351 100644 --- a/sql/create-relations-table.sql +++ b/sql/create-relations-table.sql @@ -2,24 +2,25 @@ 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)); + relation_id BIGSERIAL PRIMARY KEY, + relation_from_entity BIGINT NOT NULL, + relation_to_entity BIGINT NOT NULL, + FOREIGN KEY(relation_to_entity) REFERENCES entities(entity_id), + FOREIGN KEY(relation_from_entity) REFERENCES entities(entity_id)); --- DELETE FROM relations; -INSERT INTO relations (relation_role,from_entity,to_entity) +INSERT INTO relations (relation_from_entity,relation_to_entity) VALUES -(1,6,1), -(1,6,2), -(1,6,3), -(1,6,4), -(1,6,5), -(1,6,7), -(1,6,8), -(1,5,6) +(6,1), +(6,2), +(6,3), +(6,4), +(6,5), +(6,7), +(6,8), +(6,9), +(6,10), +(6,11), +(6,12) RETURNING *;