diff --git a/.gitignore b/.gitignore index b3a6dbc..3f433b2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ venv/ */__pycache__* */migrations* */.DS_Store +/data/ +db.sqlite3 diff --git a/db.sqlite3 b/db.sqlite3 deleted file mode 100644 index e69de29..0000000 diff --git a/piomint/settings.py b/piomint/settings.py index 3ce2e42..d453014 100644 --- a/piomint/settings.py +++ b/piomint/settings.py @@ -85,10 +85,18 @@ WSGI_APPLICATION = 'piomint.wsgi.application' # https://docs.djangoproject.com/en/5.1/ref/settings/#databases #STANDART DATENBANK +# SQLite liegt bewusst in einem eigenen data/-Verzeichnis außerhalb des Quellcodes: +# Auf dem Server läuft Gunicorn als www-data, das Deployment (git pull/migrate) aber +# als root - nur so kann www-data die DB beschreiben, ohne dass der ganze Projektordner +# (inkl. .git) für den Webserver-Prozess beschreibbar sein muss. Verzeichnis wird bei +# Bedarf automatisch angelegt; data/ ist in .gitignore, landet also nie im Repo. +DATA_DIR = BASE_DIR / 'data' +DATA_DIR.mkdir(parents=True, exist_ok=True) + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'NAME': DATA_DIR / 'db.sqlite3', } }