Skip to content

Import MySQL remote sites into COW branches#378

Merged
adamziel merged 1 commit into
trunkfrom
codex/remote-clone-mysql-import
May 18, 2026
Merged

Import MySQL remote sites into COW branches#378
adamziel merged 1 commit into
trunkfrom
codex/remote-clone-mysql-import

Conversation

@adamziel
Copy link
Copy Markdown
Contributor

What it does

Allows forkpress remote clone ... --branch <branch> to work with normal MySQL-backed WordPress sites. When the synced remote cache does not include wp-content/database/.ht.sqlite, ForkPress exports the remote MySQL tables over SSH and imports them into the local SQLite sidecar before creating the COW branch.

Rationale

The previous path only worked for ForkPress-compatible remotes that already had .ht.sqlite. A standard WordPress host could sync files successfully, then fail during branch creation with:

source branch database does not exist: .../wp-content/database/.ht.sqlite

ForkPress branches need a local SQLite database so existing merge-base snapshots, row identity capture, and per-branch ID bands keep working. Importing MySQL into the cache keeps the rest of the branch/merge model unchanged.

Implementation

  • Adds a remote mysqli exporter that reads common wp-config.php database constants without booting WordPress.
  • Adds a local SQLite importer that creates tables, imports rows, preserves single-column autoincrement primary keys, and recreates secondary indexes.
  • Runs the import automatically during remote clone when the cache has wp-config.php but no .ht.sqlite.
  • Packages the new helpers in the production runtime bundle.
  • Updates the remote-site docs to explain MySQL import requirements and troubleshooting.

Testing instructions

php -l scripts/cow/mysql_export.php
php -l scripts/cow/mysql_import_sqlite.php
php -l tests/cow/mysql_import.php
make test-cow-mysql-import
CARGO_TARGET_DIR=/tmp/forkpress-cargo-target FORKPRESS_RUNTIME_BUNDLE=/dev/null cargo test -p forkpress-cli
npm test
npm run build

I also ran the remote-cache e2e slice against a local debug binary built with a current temporary runtime bundle:

FORKPRESS_E2E_ONLY=remote-cache tests/cow/e2e.sh /tmp/forkpress-cargo-target-current/debug/forkpress

Teach remote clone to export MySQL-backed WordPress databases over SSH, import them into the local SQLite sidecar, and branch with normal merge metadata and ID bands.
@adamziel adamziel merged commit 8329fda into trunk May 18, 2026
3 checks passed
@adamziel adamziel deleted the codex/remote-clone-mysql-import branch May 18, 2026 21:22
@adamziel adamziel mentioned this pull request May 18, 2026
adamziel added a commit that referenced this pull request May 18, 2026
## Release `v0.1.46`

Version bump and release metadata update for `v0.1.46`.

**Changelog draft:**
* Import MySQL remote sites into COW branches
([#378](#378))

**Full changelog:**
v0.1.45...release/v0.1.46

## Next steps

1. **Review** the changes in this pull request.
2. **Push** any additional edits to this branch (`release/v0.1.46`).
3. **Merge** this pull request to publish `v0.1.46`.

Merging will automatically build ForkPress binaries, create a GitHub
release, and update the Homebrew formula.

Co-authored-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants