heartwood every commit a ring

Centralize SQLite settings and expand PRAGMA tuning

ffe17234 by Isaac Bythewood · 24 days ago

modified status/settings/__init__.py
@@ -98,6 +98,35 @@ MEDIA_URL = 'media/'MEDIA_ROOT = BASE_DIR / "media"# Database# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = {    'default': {        'ENGINE': 'django.db.backends.sqlite3',        'NAME': BASE_DIR / 'db.sqlite3',        'OPTIONS': {            # WAL lets readers run concurrently with a writer; the scheduler            # has several worker threads, so the default rollback journal            # yields frequent "database is locked" errors. A 30s busy timeout            # gives contending writers a chance to serialize rather than            # fail, which previously stranded alert state mid-transition.            'timeout': 30,            'transaction_mode': 'IMMEDIATE',            'init_command': (                'PRAGMA journal_mode=WAL;'                'PRAGMA synchronous=NORMAL;'                'PRAGMA foreign_keys=ON;'                'PRAGMA temp_store=MEMORY;'                'PRAGMA mmap_size=134217728;'                'PRAGMA journal_size_limit=67108864;'                'PRAGMA cache_size=-20000;'            ),        },    }}# Default primary key field type# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
modified status/settings/development.py
@@ -27,17 +27,6 @@ CSRF_TRUSTED_ORIGINS = []# Database# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = {    'default': {        'ENGINE': 'django.db.backends.sqlite3',        'NAME': BASE_DIR / 'db.sqlite3',    }}# Email# https://docs.djangoproject.com/en/4.0/topics/email/#console-backend
modified status/settings/production.py
@@ -44,22 +44,7 @@ SESSION_COOKIE_SECURE = True# Database# https://docs.djangoproject.com/en/4.0/ref/settings/#databasesDATABASES = {    "default": {        "ENGINE": "django.db.backends.sqlite3",        "NAME": "/data/db/db.sqlite3",        "OPTIONS": {            # WAL lets readers run concurrently with a writer; the scheduler            # has several worker threads, so the default rollback journal            # yields frequent "database is locked" errors. A 30s busy timeout            # gives contending writers a chance to serialize rather than            # fail, which previously stranded alert state mid-transition.            "timeout": 30,            "init_command": "PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL;",            "transaction_mode": "IMMEDIATE",        },    }}DATABASES["default"]["NAME"] = "/data/db/db.sqlite3"# Email