Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve database setup #216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ Alternativ kann die Datenbank über die Skripte in `data/db` manuell erstellt we

```bash
cd data/db
psql --command "CREATE DATABASE fisumwelt;"
psql -d fisumwelt --command "CREATE EXTENSION postgis;"
psql -d fisumwelt --command "CREATE USER auikadmin with password 'secret';"
createdb fisumwelt
createuser -P auikadmin
psql -d fisumwelt -f version1_0_schema.sql
psql -d fisumwelt -f updateTo_1_1_0.sql
```
Expand Down
32 changes: 0 additions & 32 deletions data/db/version1_0_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ SET search_path = awsv, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 194 (class 1259 OID 5901596)
Expand Down Expand Up @@ -379,8 +378,6 @@ CREATE TABLE gefaehrdungsstufen (

ALTER TABLE gefaehrdungsstufen OWNER TO auikadmin;

SET default_with_oids = true;

--
-- TOC entry 204 (class 1259 OID 5901654)
-- Name: jgs; Type: TABLE; Schema: awsv; Owner: auikadmin; Tablespace:
Expand Down Expand Up @@ -414,7 +411,6 @@ CREATE TABLE jgs (

ALTER TABLE jgs OWNER TO auikadmin;

SET default_with_oids = false;

--
-- TOC entry 205 (class 1259 OID 5901660)
Expand Down Expand Up @@ -999,8 +995,6 @@ ALTER TABLE basis_sachbearbeiter_id_seq OWNER TO auikadmin;
ALTER SEQUENCE basis_sachbearbeiter_id_seq OWNED BY sachbearbeiter.id;


SET default_with_oids = true;

--
-- TOC entry 234 (class 1259 OID 5901796)
-- Name: standort; Type: TABLE; Schema: basis; Owner: auikadmin; Tablespace:
Expand Down Expand Up @@ -1050,7 +1044,6 @@ ALTER TABLE basis_standort_id_seq OWNER TO auikadmin;
ALTER SEQUENCE basis_standort_id_seq OWNED BY standort.id;


SET default_with_oids = false;

--
-- TOC entry 236 (class 1259 OID 5901803)
Expand Down Expand Up @@ -1264,8 +1257,6 @@ CREATE TABLE aba (

ALTER TABLE aba OWNER TO auikadmin;

SET default_with_oids = true;

--
-- TOC entry 245 (class 1259 OID 5901856)
-- Name: abaverfahren; Type: TABLE; Schema: elka; Owner: auikadmin; Tablespace:
Expand All @@ -1281,7 +1272,6 @@ CREATE TABLE abaverfahren (

ALTER TABLE abaverfahren OWNER TO auikadmin;

SET default_with_oids = false;

--
-- TOC entry 246 (class 1259 OID 5901862)
Expand Down Expand Up @@ -1679,8 +1669,6 @@ ALTER TABLE e_einleitungsstelle OWNER TO auikadmin;

SET search_path = oberflgw, pg_catalog;

SET default_with_oids = true;

--
-- TOC entry 250 (class 1259 OID 5901927)
-- Name: entwaesserungsgrundstueck; Type: TABLE; Schema: oberflgw; Owner: auikadmin; Tablespace:
Expand Down Expand Up @@ -1750,7 +1738,6 @@ ALTER TABLE e_entwaesserungsgrundstueck OWNER TO auikadmin;

SET search_path = labor, pg_catalog;

SET default_with_oids = false;

--
-- TOC entry 251 (class 1259 OID 5901939)
Expand Down Expand Up @@ -1973,8 +1960,6 @@ ALTER TABLE e_probenahme_ueberwachungsergeb OWNER TO auikadmin;

SET search_path = oberflgw, pg_catalog;

SET default_with_oids = true;

--
-- TOC entry 256 (class 1259 OID 5901992)
-- Name: sonderbauwerk; Type: TABLE; Schema: oberflgw; Owner: auikadmin; Tablespace:
Expand Down Expand Up @@ -2515,7 +2500,6 @@ ALTER SEQUENCE z_aba_verfahren_id_seq OWNED BY z_aba_verfahren.id;

SET search_path = indeinl, pg_catalog;

SET default_with_oids = false;

--
-- TOC entry 267 (class 1259 OID 5902304)
Expand Down Expand Up @@ -3750,8 +3734,6 @@ ALTER TABLE view_atl_analyseposition_alt OWNER TO auikadmin;

SET search_path = oberflgw, pg_catalog;

SET default_with_oids = true;

--
-- TOC entry 315 (class 1259 OID 5902625)
-- Name: afs_niederschlagswasser; Type: TABLE; Schema: oberflgw; Owner: auikadmin; Tablespace:
Expand Down Expand Up @@ -7903,17 +7885,3 @@ ALTER TABLE labor.parameter ADD COLUMN analysemethode_id integer;

UPDATE labor.analyseposition SET methode_id = parameter.analysemethode_id FROM labor.parameter WHERE analyseposition.parameter_id = parameter.ordnungsbegriff;
UPDATE labor.analyseposition SET methode_id = 1 WHERE analyseposition.methode_id is null;


CREATE TABLE labor.gebuehren
(
id serial,
bezeichnung character varying,
wert integer,
_enabled boolean NOT NULL DEFAULT true,
_deleted boolean NOT NULL DEFAULT false,
CONSTRAINT gebuehren_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
);
6 changes: 3 additions & 3 deletions docker/init_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ psql -q -d $DB_NAME --command "CREATE EXTENSION postgis;"
psql -q -d $DB_NAME --command "CREATE USER ${USERNAME} with password '${USER_PW}';"

echo "Applying schema"
psql -q -d $DB_NAME -f $schema_file
psql -q -d $DB_NAME -f $update_file_1_1_0
psql -q -d $DB_NAME -v ON_ERROR_STOP=on -f $schema_file
psql -q -d $DB_NAME -v ON_ERROR_STOP=on -f $update_file_1_1_0

psql -q -d $DB_NAME -f $import_script <$schema_dir/import.csv
psql -q -d $DB_NAME -v ON_ERROR_STOP=on -f $import_script <$schema_dir/import.csv