Files
errors.bitreport.pt/database/error_reporting/README.md
T
1sonhadorandPaperclip 4604606033 feat(errors): migrate error-reporting stack from PostgreSQL to MariaDB (BIT-255)
Replace Postgres with MariaDB 11 in docker-compose; convert all
database/error_reporting and db/migrations SQL to InnoDB-friendly syntax
(DATETIME(6), AUTO_INCREMENT, ON DUPLICATE KEY). Run admin portal DDL in the
same migrate one-shot as error_reporting.

Switch ingest-api, collector-worker, and api from pg to mysql2 (pools,
parameterized queries, transactions). Align ingest writes with
er_incident_occurrences and include project_id on idempotency inserts.

Add scripts/run-mysql-migrations.sh for host-side applies; update LXC
run-migrate/verify, deployment docs, and .env.example (mysql://, ER_MYSQL_*).

Verified: npm run build + npm test in ingest-api and collector-worker;
npm run build in api. Full docker compose not run here (no local daemon).

Co-Authored-By: Paperclip <[email protected]>
2026-03-22 19:29:11 +00:00

1.6 KiB

Error Reporting Database (BIT-178)

This folder contains the relational data model for the Error Reporting platform epic (BIT-154), implemented for task BIT-178.

Status and dependency:

  • Runtime target is MariaDB 10.11+ (or MySQL 8+) with InnoDB; Compose and LXC apply the same SQL.
  • Schema changes must continue through versioned SQL migrations only (up + down), never ad hoc DDL.

Migration layout

Migrations are versioned and reversible (up + down), timestamped, and idempotent:

  1. 20260322043000_create_error_reporting_core.*
  2. 20260322044000_create_error_occurrences_and_states.*
  3. 20260322044500_add_ingest_idempotency.*
  4. 20260322045000_create_collectors_retention_and_audit.*

Admin portal tables (admin_users, refresh tokens, audit) live under db/migrations/ at repo root and are applied in the same database by scripts/docker-migrate.sh / deploy/lxc/run-migrate.sh.

Apply manually (example)

From the repository root, with mariadb client and a mysql:// (or discrete ER_MYSQL_*) connection:

./scripts/run-mysql-migrations.sh

Or run individual files:

mariadb -h 127.0.0.1 -u er_app -p"$ER_MYSQL_PASSWORD" error_reporting \
  < database/error_reporting/migrations/20260322043000_create_error_reporting_core.up.sql
# ... remaining migrations + db/migrations/*.sql + seed as in scripts/docker-migrate.sh

Rollback in reverse order with the matching *.down.sql files.

Dev seed fixtures

For local integration tests:

  • seed/dev_two_projects.sql creates two sample projects and ingest keys.
  • seed/dev_collector_http_fixture.sql creates one demo HTTP polling source.