Stage 1: Problem
The Problem
You are building a multi-tenant SaaS platform that must support multiple databases. Some tenants use MySQL, others use PostgreSQL. For each database, you need three things that must match:
- A Repository — handles CRUD with database-specific SQL dialect
- A MigrationRunner — runs schema migrations using the right driver
- A Seeder — populates initial data using the correct connection
Right now you only support MySQL. Your PM says: "We signed three PostgreSQL clients this week. And the team in Berlin wants MongoDB support by Q3."
Before reading further: How would you structure this so that adding a new database means implementing one set of components, with no risk of mixing a MySQL repository with a PostgreSQL migration runner?