Skip to content

MySQL

@branchly/datasource-mysql gives each branch its own database (schema) on your MySQL server, named <prefix>_<key>.

CapabilityValueVia
instantCloneSQL-level replay (see below)
snapshotSnapshots are ordinary databases
isolatedPerBranchOne database per branch
datasource: {
use: 'mysql',
url: env('DATABASE_URL'),
prefix: 'app',
}
OptionDefaultMeaning
url(required)Your existing connection string. branchly keeps host + credentials, swaps the database.
prefix'app'Database name prefix; everything branchly creates starts with <prefix>_.

MySQL has no template mechanism, so this adapter clones at the SQL level:

  1. Replays each table’s SHOW CREATE TABLE definition into the target database.
  2. Copies data with INSERT … SELECT, with foreign-key checks disabled during the copy so table order doesn’t matter.
  3. Recreates views against the target schema, retrying in dependency order so views-on-views resolve.

For development-sized databases this is fast — not Postgres-template fast, but easily quick enough that branch switches stay pleasant. The result is a fully independent database: writes to the clone never touch the source (the conformance kit verifies exactly this).

The connection’s user must be able to CREATE DATABASE, DROP DATABASE, and read information_schema — standard for a development root or admin user.