MariaDB, plain SQL, and Umzug migrations
- Deciders: David Bauer, Julian Bäume
- Date: 2026-06-12
Status
Accepted
Context
The original booking-service persists to MySQL (bookingdb, 5 tables: user, poll, event, voter, vote) via JPA/Hibernate with app-generated UUIDv4 primary keys and Liquibase migrations. Booking replaces that service and must offer a clear migration path for the existing bookingdb data — but we are not bound to keep the old schema unchanged forever, and we are free to diverge from it where it makes sense.
We need to pick a database engine, an access style (ORM vs. plain SQL), and a migrations tool for booking on its own merits, weighing how easy it is to bring the existing data across against the shape of the domain we actually have.
Decision
Booking uses MariaDB with plain SQL (named placeholders, no ORM) and Umzug for migrations, because:
- It gives the shortest, lowest-risk migration path for the existing data. The current data lives in a MySQL-compatible
bookingdb. Staying on MariaDB means the existing data moves across with a plain dump/restore (or, where operationally convenient, by adopting the existing database directly), rather than a cross-engine, type-mapping data-migration project. We keep the freedom to evolve the schema afterwards; we just don't pay a cross-engine conversion cost to get the data in. - The initial migration (
src/migrations/booking/001-initial-schema.ts) ports the Liquibase changesets 1-6 asCREATE TABLE IF NOT EXISTSstatements. TheIF NOT EXISTSidempotency means the migration runner is a no-op against abookingdbthat already has these tables and only creates what is genuinely missing — so the same code path works whether we start from an empty database or from migrated data. @open-xchange/fastify-sdk's MariaDB support is first-class (pool lifecycle, readiness checks,DATABASES/DB_<NAME>_*convention, Umzug integration) — see ADR-0003 — so MariaDB is a well-supported default with no extra infrastructure to build.- The domain is small (5 tables, no JSON columns, no need for
LISTEN/NOTIFYor vector search), so the differentiating features of a heavier engine like PostgreSQL would go unused here. MariaDB is a good fit for what this service actually stores. - Plain SQL over an ORM matches the size and shape of the domain — the diff-based upsert semantics in
src/services/polls.tsare transaction-shaped, not object-graph-shaped, and are easier to reason about as explicit SQL than through an ORM abstraction.
We are not committing to schema compatibility with the Java service. The initial schema mirrors it because that is the cheapest way to land the existing data, but we are free to migrate the schema forward from there. The database schema is the one interface booking inherits that has a consumer outside this repository (existing production data); the HTTP API is not (see ADR-0005).
Consequences
Positive
- The existing
bookingdbdata has a clear, low-risk path onto booking: dump/restore, or adopt the existing database in place, with no cross-engine conversion. - No new database technology is introduced to operators who already run the Java service's MySQL/MariaDB.
- Plain SQL keeps the diff-upsert logic (
putPollEvents/putPollVoters/putPollVotes) transparent and directly portable from the originalPollService.java.
Negative
- We start on the Java service's schema shape, so any divergence we want (renames, normalization, new columns) is future migration work rather than something baked in from the start — an acceptable trade for a cheap initial data migration.
- MariaDB forgoes JSONB,
LISTEN/NOTIFY, and a richer extension ecosystem — not a problem for Booking's current domain, but a constraint if the domain grows in that direction. - No ORM means schema changes and query correctness are the developer's responsibility; there is no compile-time check that a query matches the schema.
References
src/migrations/booking/001-initial-schema.ts(ported Liquibase changelog, idempotent initial schema)src/services/polls.ts(diff-based upsert transactions)- ADR-0003

