diff --git a/README.md b/README.md index c69ec8e..501b2a8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ $ python3 -m venv .venv $ source .venv/bin/activate ``` +(to leave the virtual environment, the command is simply `deactivate`) + ## Configure the Environment ```bash @@ -68,7 +70,9 @@ If you run into issues with `psycopg2` you may need to run the following: $ pip3 uninstall psycopg2 && pip3 install --no-binary :all: psycopg2 ``` -## Ensure Postgres is running and accessible +## Set up database + +### Method 1 You should be able to connect to Postgres: @@ -86,6 +90,34 @@ to change the Postgres authentication options (NB on Fedora / Centos, $ echo "ALTER USER postgres WITH PASSWORD 'postgres';" | psql -U postgres ``` +### Method 2 + +First you need to switch to the user called postgres - in Linux do + +```bash +$ sudo su postgres +``` +Then get an interactive postgres shell + +``` +$ psql +``` + +Then create a database and a user, and ensure to make the user a superuser (otherwise you will run into trouble when doing the migration and it tries to enable the postgis extension). + +```bash +postgres=# create database ojuso; +postgres=# create user ojuso WITH PASSWORD 'ojuso'; +postgres=# alter role ojuso SET client_encoding TO 'utf8'; // this is recommended for django +postgres=# alter role ojuso SET default_transaction_isolation TO 'read committed'; // so is this +postgres=# grant all privileges on database ojuso to ojuso; +postgres=# alter user ojuso with superuser; +``` +Type `\q` to exist the postgres shell. + +Then, in `ojuso-map/ojusomap/settings.py`, edit the `DATABASES` section to add the database name, user and password, which are all 'ojuso' unless you chose different ones in the previous step. + + ## Run The Migrations ```bash diff --git a/system-requirements-debian.txt b/system-requirements-debian.txt index 2285a2b..eb7ef71 100644 --- a/system-requirements-debian.txt +++ b/system-requirements-debian.txt @@ -2,3 +2,4 @@ libgdal-dev python3-gdal gdal-bin postgresql +postgis