Navigation Menu

Skip to content

Commit

Permalink
add option to use postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Sep 23, 2021
1 parent 95fa893 commit 4e8c61b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Makefile
Expand Up @@ -36,6 +36,9 @@ help:
@echo " make po -- create new po files from the source"
@echo " make mo -- create new mo files from the translated po files"
@echo " make release -- build everything required for a release"
@echo " make start-postgres -- start the local postgres cluster"
@echo " make stop-postgres -- stops the local postgres cluster"
@echo " make create-postgres -- create the local postgres cluster (only works on ubuntu 20.04)"
@echo

.PHONY: install
Expand Down Expand Up @@ -146,3 +149,23 @@ release:
$(VIRTUAL_ENV)/bin/python3 -m pip install -r requirements.txt -q
$(VIRTUAL_ENV)/bin/python3 manage.py compilemessages -v0
$(VIRTUAL_ENV)/bin/python3 manage.py collectstatic --noinput -v0

.PHONY: start-postgres
start-postgres:
sudo -u postgres PGDATA=pgsql PGPORT=5556 /usr/lib/postgresql/12/bin/pg_ctl start

.PHONY: stop-postgres
stop-postgres:
sudo -u postgres PGDATA=pgsql PGPORT=5556 /usr/lib/postgresql/12/bin/pg_ctl stop

.PHONY: create-postgres
create-postgres:
if [ -d "pgsql" ]; then \
echo "postgresql has already been initialized"; \
else \
sudo install -d -m 744 -o postgres -g postgres pgsql; \
sudo -u postgres /usr/lib/postgresql/12/bin/initdb pgsql; \
sudo -u postgres PGDATA=pgsql PGPORT=5556 /usr/lib/postgresql/12/bin/pg_ctl start; \
sudo -u postgres PGDATA=pgsql PGPORT=5556 /usr/lib/postgresql/12/bin/createuser -s django; \
sudo -u postgres PGDATA=pgsql PGPORT=5556 /usr/lib/postgresql/12/bin/createdb -O django django; \
fi
13 changes: 12 additions & 1 deletion README.md
Expand Up @@ -32,9 +32,20 @@ adhocracy+ is designed to make online participation easy and accessible to every
make test

### Start a local server:

make watch

### Use postgresql database for testing:
run the following command once:
```
make create-postgres
```
to start the testserver with postgresql, run:
```
export DATABASE=postgresql
make start-postgres
make watch
```

Go to http://localhost:8004/ and login with admin@liqd.net | password

## Installation on a production system
Expand Down
14 changes: 14 additions & 0 deletions adhocracy-plus/config/settings/dev.py
Expand Up @@ -32,3 +32,17 @@
BASE_URL = 'http://localhost:8004'
CAPTCHA_URL = 'https://captcheck.netsyms.com/api.php'
SITE_ID = 1

if os.getenv("DATABASE") == "postgresql":
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'django',
'PASSWORD': '',
'HOST': '',
'PORT': '5556',
'OPTIONS': {
},
}
}

0 comments on commit 4e8c61b

Please sign in to comment.