Dang Vuong Binh

Moving a live marketplace from MySQL on Vitess to PostgreSQL, one domain at a time

HouseNow's listings, leads, wallet and ads data lived in MySQL on Vitess. We moved it to PostgreSQL while the product kept shipping: replicate, write to both, move writes domain by domain, verify the archives, then delete the old database.

Period
8 Jun 2026 – 6 Oct 2026
Duration
120 days
Role
Engineering Manager – Backend Lead
Organisation
HouseNow, Housenow JSC
Team
Shared across the backend team; one backend engineer and I wrote the largest shares

Results

Results of the Live MySQL to PostgreSQL migration case study
FigureMeasure
120days from the first PostgreSQL schema to deleting the old database8 June to 6 October 2026, with feature work shipping throughout.
154operational scripts reviewed: 143 converted, 11 retired with a written reasonFinal cleanup, 1 October 2026.
211migration commits across 127 ticketsCommit and ticket history, June to October 2026.

Context and constraints

The marketplace's core (listings, leads, loans, subscriptions, the broker wallet, ads and tracking) ran on PlanetScale MySQL with Vitess, with relations enforced in application code.

The target was PostgreSQL, where scheduled jobs, functions, triggers and vector search could live inside the database and be kept as desired-state SQL in the repository.

  • Millions of API calls a day and no maintenance window.
  • The rest of the team kept shipping: ads, video and data-pipeline work landed during the migration.
  • Money-bearing tables: the broker wallet, credits and the ads ledger.
  • 154 operational scripts read or wrote the old database.

My role and decision rights

I started the migration with the first PostgreSQL schema and its separate Prisma schema, set up change-data-capture replication on AWS, wrote the final Vitess cleanup, and wrote reliability fixes along the way: idempotent mirrored writes, function-drift detection and deadlock fixes.

The per-table dual writes and backfills were shared across the team; one backend engineer and I wrote the largest shares of the 211 migration commits.

Decision rights: as backend lead I owned the database architecture, the order of the domains and the decision to delete the old database.

Architecture

  1. 1. Expand 8 Jun
    The app reads and writes MySQL; an empty PostgreSQL schema is created.

  2. 2. Replicate 8 Jul
    Change-data capture copies MySQL into PostgreSQL.

  3. 3. Dual-write and backfill Jul–Aug
    Writes go to both; backfills fill the history, table by table.

  4. 4. Move writes Sep
    Domain by domain, PostgreSQL becomes the source of truth.

  5. 5. Contract 21 Sep – 1 Oct
    Replication removed; every script converted or retired.

  6. 6. Archive and delete 6 Oct
    Verified archives in S3, then the MySQL database is deleted.

Fig. 2 Expand, migrate, contract: the two databases in six steps. Green marks where writes land.

Decisions

Expand and contract instead of a cutover weekend

A one-night cutover would need a maintenance window, a full rehearsal and a rollback plan for a database that changed every hour.

Options considered
OptionAssessment
Dump and restore in a maintenance windowFast on paper; everything has to work on one night.
Stay on MySQL and work around itNo migration risk, and no functions, scheduled jobs or vectors in the database.
Replicate, dual-write, move writes per domain, contract (chosen)Slow and reversible at every step.

We will replicate with change-data capture, add dual writes and backfills table by table, move writes one domain at a time (listings, leads, loans, subscriptions, tracking), then remove replication and delete the old database only behind verified archives.

Gained

  • No single night where everything had to work.
  • Each domain could be checked, and rolled back, on its own.
  • Feature work continued throughout.

Paid

  • For weeks every write path existed twice and had to stay consistent.
  • Drift between the databases needed idempotent mirrored writes and drift checks.
  • 120 days of overlap instead of one weekend.

Delete the old database only behind verified archives

Keeping the old cluster "just in case" costs money every month; deleting it without proof risks data.

Options considered
OptionAssessment
Keep the old database runningSafe, and a second bill with no end date.
Delete after a spot checkCheap, and nobody can prove completeness later.
Archive, verify by checksum and exact row count, then delete (chosen)Proof on record before the bill stops.

We will write final logical backups to an encrypted, versioned, deletion-protected S3 bucket, verify each by checksum and exact row count, then delete the MySQL database.

Gained

  • The old bill stopped on 6 October 2026.
  • Evidence of completeness is on record.

Paid

  • Archives are kept for 30 days, and no full restore drill was run before deletion.

Change the engine, keep the provider

Changing the database engine and the vendor at the same time doubles the unknowns during a live migration.

Options considered
OptionAssessment
Self-managed or AWS-native PostgreSQLCloser to the rest of the platform, and a second change at once.
A new managed vendorNew operations and billing to learn mid-migration.
The same provider's PostgreSQL with a read replica (chosen)One change at a time.

We will move to PlanetScale's PostgreSQL with a read replica, keep functions, triggers and pg_cron jobs as desired-state SQL in the repository, and check the production schema in CI.

Gained

  • Familiar operations and billing.
  • Schema drift is caught in CI, not in production.

Paid

  • Still one vendor for the core database; moving to AWS-native PostgreSQL would be a separate project.

Outcomes

  • The MySQL database was deleted on 6 October 2026 after archive verification; on 20 October the runtime moved to the standard PostgreSQL driver.
  • Every script that touched the old database was converted (143) or retired with a reason (11).
  • PostgreSQL now also runs the scheduled jobs, functions and vector recommendations (pgvector).
  • Guardrails stayed behind: idempotent mirrored writes, function-drift detection and a CI check of the production schema.

What I would do differently

Run a full restore drill from the archives before deleting the source, not only checksums and row counts.

Write the domain-by-domain sequence as one decision record at the start; it lived in tickets and commits, which made it harder for newcomers to follow.

Stack

  • PlanetScale MySQL (Vitess)
  • PlanetScale Postgres
  • Change-data capture on EC2
  • Prisma
  • Kysely
  • pg_cron, pgvector
  • S3
  • GitHub Actions