Skip to content

[FEATURE][DB]: MariaDB support testing and documentation #288

@crivetimihai

Description

@crivetimihai

🧭 Epic - MariaDB Support (alongside PostgreSQL & SQLite)

Field Value
Title Add full MariaDB 10.6+ compatibility (runtime, migrations, CI, docs)
Goal Run the Gateway with a MariaDB backend simply by changing the SQLAlchemy URL (e.g., mariadb+mariadbconnector://…). Provide a one-liner Docker Compose service, optional Helm values, green CI matrix, and updated docs.
Why now Several downstream teams operate on MariaDB-only clusters. Supporting it widens adoption and lets us validate SQL-dialect abstractions before 1.0 GA.
Depends on Alembic migration framework; Validation & Schema Enforcement epic (cross-dialect JSON handling).

This feature validates that SQLAlchemy and Alembic migrations are implemented correctly, and provides an additional baseline to compare performance with.


🧭 Type of Feature

  • Database portability
  • DevOps / CI
  • Documentation

🙋‍♂️ User Stories

# Persona Need Acceptance Criteria
1 Platform engineer Spin up Gateway + MariaDB in Docker Compose docker compose -f docker-compose.mariadb.yml up starts Gateway, Alembic auto-migrates, health checks pass.
2 SRE running Helm Deploy Gateway with cluster-managed MariaDB Setting db.type=mariadb in values.yaml generates a valid Secret & connection string; pods reach Ready.
3 Developer CI asserts my PR works on all DBs GitHub Actions job shows ✨ green for sqlite / postgres / mariadb matrix.
4 Doc reader Find config & caveats in docs README & “Databases” guide list supported engines, connection URLs, engine-specific notes.

🔧 Task Breakdown

  1. SQLAlchemy & Drivers

    • Pin mariadb>=1.1.4 (connector) in requirements.in.
    • Update config.py to accept DB_DRIVER env var default → mariadb+mariadbconnector.
  2. Alembic Dialect Support

    • Add MariaDB branch in alembic/env.py (engine.dialect.name == "mariadb").
    • Replace postgresql.UUIDString(36) if dialect is MariaDB.
    • Migrate JSONB → JSON type; fallback to TEXT for 10.3-.
  3. Schema Fix-ups

    • Shorten FK names (<= 64 chars) via naming_convention for MariaDB.
    • Replace ARRAY columns with comma-separated VARCHAR or link-table.
  4. Test Matrix

    • GitHub Actions matrix { DB: sqlite, postgres, mariadb }.
    • GitHub Service container: mariadb:10.6, env MARIADB_ROOT_PASSWORD: test.
    • Parametrise pytest fixture to spin engine per DB.
  5. Docker Compose

    • docker-compose.mariadb.yml adds:

      mariadb:
        image: mariadb:10.6
        environment:
          MARIADB_ROOT_PASSWORD: gateway
        ports: ["3306:3306"]
    • Gateway service gets DB_URL: mariadb+mariadbconnector://root:gateway@mariadb:3306/gateway.

  6. Helm Chart

    • values.yaml

      db:
        type: mariadb  # postgres|sqlite|mariadb
        host: mariadb
        port: 3306
        user: gateway
        password: gateway
    • Conditional template renders driverClassName, liveness query.

  7. Documentation

    • “Supported Databases” page: sample URLs, limitations (no partial JSONPath index, FK length).
    • README quick-start snippet for Compose & Helm.
  8. Migration Guide

    • Doc section: “Migrating Postgres → MariaDB” (export/import with mysqldump caveats).
  9. Observability

    • DB metrics labels include engine="mariadb".
  10. Release Notes & Changelog

    • Note new driver dependency and env vars.

📓 Implementation Notes / Caveats

  • JSON – MariaDB ≥10.5 stores JSON as LONGTEXT with type validation; no JSONB indexing.
  • UUIDs – stored as CHAR(36); minor perf hit vs native uuid in Postgres.
  • Transactions – default engine InnoDB; tests enforce READ COMMITTED isolation.
  • Max key length – 3072 bytes (utf8mb4) ⇒ watch composite indexes.

🔄 Alternatives Considered

Approach Pros Cons Decision
Stick to Postgres only Less code, best features Blocks teams on MariaDB, reduces adoption

✅ Definition of Done

  • All unit & integration tests pass on sqlite-latest, postgres-16, mariadb-10.6 in CI.
  • docker compose -f docker-compose.mariadb.yml up starts without manual tweaks.
  • Helm chart with db.type=mariadb deploys successfully on kind.

Metadata

Metadata

Assignees

Labels

devopsDevOps activities (containers, automation, deployment, makefiles, etc)enhancementNew feature or requesthelmHelm chartpythonPython / backend development (FastAPI)

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions