mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-07-03 16:31:23 +02:00
caef666c02
- compose: add optional postgres service (postgres:17-alpine, profile 'postgres', healthcheck, postgres_data volume); POSTGRES_* derive from DATABASE_* (single source of truth). DATABASE_* env added to migrate/ collector/api; migrate depends_on postgres with required:false so SQLite deployments are unaffected. - alembic/env: resolve the URL via CommonSettings.effective_database_url so DATABASE_BACKEND=postgres is honoured (previously DATABASE_URL/DATA_HOME only -> would silently migrate SQLite). - migrations: normalize_public_key uses STRING_AGG + HAVING COUNT(*) on Postgres (was SQLite GROUP_CONCAT + alias); raw_packets uses sa.JSON() not the sqlite dialect type. - database: fix _to_async_url to map postgresql+psycopg2:// (what the config assembles) to asyncpg, so API async sessions work on Postgres; resolve the search_path schema from DATABASE_SCHEMA env when not passed explicitly. Validated against a live postgres:17: db upgrade builds all 13 tables in the meshcorehub schema with correct native types (is_observer boolean, decoded json) and alembic_version stamped; the upsert, JSON/timestamptz round-trip, and asyncpg async sessions all work. SQLite suite still green (1061 passed). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>