Skip to content

feat(infra): Postgres backend (currently SQLite-only) #10

Description

@Metbcy

Problem

The backend uses aiosqlite directly for all persistence. SQLite is great for single-host deploys but caps out for:

  • Multi-worker (file-based locking + WAL contention)
  • Multi-instance HA
  • Operational tooling (backup/restore, replication, observability)

The current code also has direct SQL strings sprinkled throughout backend/securescan/database.py and elsewhere. A Postgres adapter requires rewriting those.

Acceptance criteria

  • New SECURESCAN_DATABASE_URL env var (postgres:// or sqlite://, defaults to sqlite for back-compat).
  • aiosqlite usage abstracted behind a small adapter layer that supports both.
  • Migrations work on both DBs (this likely forces feat(infra): tracked migrations / Alembic #11 — tracked migration system — first).
  • All 887 tests pass against Postgres in CI.
  • Documented in docs/src/deployment/.

Suggested approach

Use SQLAlchemy 2.0 async (asyncpg driver for postgres, aiosqlite for sqlite). Or: thin adapter that translates a few SQLite-specific SQL idioms to Postgres equivalents (idempotent ALTER TABLE pattern → DO blocks, etc.).

Difficulty

~3 days. Touches every persistence call site; needs careful test coverage.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededinfraCI / build / deployment

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions