Take a look around.
Node.js / Databases

Supporting PostgreSQL and MySQL doesn’t move your data

By Lan T.6 min read

Supporting two database engines means the application can talk to either one. It does not copy the old records, reconcile conflicting identities or decide when the new database takes over. Those are separate pieces of work, with their own checks and recovery plan.

Diagram: existing records, then target schema, then transfer plan, then reconciled records.
Adapter support and moving existing records are separate pieces of work.Open the full diagram ↗

What RoleHarbor shares

RoleHarbor connects ReactJS member and staff interfaces to Hono services and a Kysely query layer. The hosted application runs on Cloudflare Workers and uses a dedicated PostgreSQL database through Hyperdrive. The source also has a MySQL adapter; the public deployment does not run both engines at once.

The shared membership rules sit above the database adapters. Selecting a MySQL connection changes where the services read and write; it does not copy PostgreSQL records, translate an existing schema or reconcile pending billing and access work.

  • ReactJS member catalogue and staff workspace
  • Hono, TypeScript and Kysely for shared membership services
  • PostgreSQL through Hyperdrive in the hosted system; MySQL supported by the source adapter
PartShared or selected?
React catalogue and staff workspaceShared interface
Hono membership, billing and access servicesShared application rules; hosted on Cloudflare Workers
Kysely queriesShared repository layer, with dialect-specific handling where needed
PostgreSQL / pg or MySQL / mysql2Hosted demo: PostgreSQL through Hyperdrive. MySQL: separate source adapter.
Existing records and migration historyBelong to each database; not copied by selecting an adapter

The same types do not prove the same behaviour

A query can compile and still behave differently with another database’s comparison rules or column definitions. In a membership system, the useful questions are concrete: does an identifier still identify the same payment, does an expiry fall on the same instant, and can the same purchase create a second access record?

RoleHarbor makes several choices explicit. Core access dates are stored as canonical UTC strings. The MySQL driver uses UTC, and the migration script requires a binary database collation. That requirement is intended to preserve case-sensitive provider identifiers. It belongs to this implementation; changing an existing database’s collation needs its own review.

Decision in the sourceWhat to check with representative data
Application and provider IDsCase differences, lengths, uniqueness and reference mapping
Core UTC date strings and separate auth schemaExpiry boundaries, null values and driver conversion
Integer amounts and a currency fieldAmounts and totals stay associated with the correct currency
Unique payment reference on an entitlementA repeated payment cannot silently create another entitlement
Database-specific schema and indexesConstraints, query behaviour and migration history on each target

Schema migrations are another part of the handoff

RoleHarbor uses a tracked Kysely Migrator for its core tables and indexes. The auth library has a separate migration plan; the script stops when that plan reports unsafe changes or schema problems. The application’s TypeScript interfaces do not replace those database definitions.

For an existing installation, I would review which migrations have already run before proposing the next change. An applied migration is part of that installation’s history. Editing its old file is not a reliable way to update every database that has already used it.

Plan the transfer around records you can reconcile

A useful transfer plan names the old system, the target, the records that must survive and the person who approves the comparison. It also states which system can accept writes at each stage. Otherwise, two apparently healthy applications can disagree about which payment or access change happened last.

This is a planning worksheet, not a transfer that has been run for a customer. The exact process depends on the source schema, database versions, write volume and hosting setup.

Before switchingEvidence to ask for
Inventory identities and referencesA source-to-target map, including duplicates and exceptions
Prepare the target schemaReviewed migrations, constraints and comparison rules
Back up and rehearse a restoreA recovery run that can actually read the restored records
Transfer and compareCounts, references, amounts by currency, access states and selected member histories
Rehearse the final catch-upA checkpoint for writes, incoming billing events and unfinished jobs
Agree on recoveryAn owner, decision point and a way to account for writes after cutover

Changing the connection back is not a complete rollback

Once the new database accepts writes, the old one may be behind. Switching the application back can lose those newer decisions unless the recovery process accounts for them. That includes pending work: a completed provider action must not be repeated merely because a job was copied or restarted.

Before choosing a cutover window, decide how to stop or catch up writes, preserve event checkpoints and reconcile access changes. A backup is useful, but a restore rehearsal and a post-cutover write plan answer different questions.

What the current RoleHarbor deployment demonstrates

The hosted RoleHarbor system uses PostgreSQL through Hyperdrive, with separate database credentials for this application. Its member records, paid periods and pending work stay in SQL while Cloudflare Queues and scheduled recovery handle follow-up processing.

Database backups and isolated restore checks are part of its operating handoff. They demonstrate recovery for this PostgreSQL installation, rather than a customer migration between engines. A PostgreSQL-to-MySQL transfer still needs its own mapping, reconciliation and cutover review.

The shared staff demo lets you inspect the hosted workspace as Owner, Administrator or Viewer. Its Reset demo button restores Stripe test and Discord connection settings only; it does not change database engines, copy records or restore a backup.

Start with the database you already have

If you are considering a switch, bring the current engine and version, a description of the important records, the reason for changing and the amount of interruption the workflow can tolerate. We can then separate adapter work from schema changes and the actual data transfer.

If the aim is simply to support an existing MySQL installation, that may be a smaller job than moving everything to PostgreSQL. The first useful result is an agreed scope and a comparison you can review, rather than a promise that both engines are interchangeable.

Explore the working system

Try RoleHarbor for yourself.

RoleHarbor serves one business and one Discord server. Try the member journey or sign in as Owner, Administrator or Viewer. The demo uses Stripe test mode; no real charges are collected. Discord uses the configured demo server.

How to sign in and restore the connections
  1. Open the staff demo. The sign-in page lists the three available accounts.
  2. Choose Owner, Administrator or Viewer to fill in the email and password. Start with Viewer if you want to look around.
  3. Select Sign in. Use the workspace navigation to explore members, plans, billing and operations.
Owner
demo.owner@beemvp.comBusiness and provider settings, package-to-role mapping, room access and membership operations.
Administrator
demo.admin@beemvp.comDay-to-day membership operations, packages, billing and eligible failed-work retries.
Viewer
demo.viewer@beemvp.comRead-only access to the workspace. Changes are refused by the server.

Shared password: RoleHarbor@Demo

These public accounts keep fixed sign-in details. They cannot change staff accounts, passwords or MFA. Private staff accounts retain the full team and security controls.

Restore the default connections

Sign in as Owner, open Connections and choose Reset demo. Enter the shared password, then select Restore default connections.

This restores the saved Stripe test keys and Discord connection settings. It keeps members, payments, plans and activity. It does not undo Discord room changes, reverse payments or reset the whole workspace.

This is a shared workspace, so other visitors may change its records. Use test information when trying an editable role.

Further reading & related work

Product examples and references for the decisions in this note.

Have a similar piece of work?

Tell me what needs to stay intact.

Tell me what you’re working on ↗

Keep reading