Skip to content

feat: connect through a Unix socket (MySQL and PostgreSQL) - #296

Merged
jasdeepkhalsa merged 2 commits into
masterfrom
feat/socket-connections
Nov 12, 2026
Merged

jasdeepkhalsa merged 2 commits into
masterfrom
feat/socket-connections

Conversation

@jasdeepkhalsa

Copy link
Copy Markdown
Member

Connect through a Unix-domain socket instead of TCP, on MySQL and PostgreSQL, for diff and the migration runner.

How to name the socket

  • In a config file: a socket key on the server, as A way to specify a non-standard socket? #44 asked:
    server1:
      user: root
      password: root
      socket: /Applications/MAMP/tmp/mysql/mysql.sock
  • In a URL: ?socket= for either driver, MySQL's ?unix_socket=, or libpq's ?host=<directory>. The libpq form may leave the host out of the URL: postgres://app:secret@/orders?host=/var/run/postgresql.
  • MySQL takes the socket file. PostgreSQL takes the directory holding it, and a .s.PGSQL.<port> file is read as its directory and port.
  • A MySQL server given only a socket needs no host or port.
  • The pg_dump renderer passes a socket directory as ?host=, so PostgreSQL tables are still rendered by pg_dump over a socket.

Also fixed: a config file's driver now applies when --driver isn't typed. The option's own default overrode it, so driver: pgsql in a config file was read as MySQL.

Tests

  • tests/Unit/SocketConnectionTest.php: adapter configs, URL forms and migration configs.
  • PgDumpCommandTest: the socket connection string. It fails without the change.
  • DiffCommandTest: a config file's driver, run end to end on SQLite. It fails without the change.
  • Checked by hand against MySQL 8.4 and PostgreSQL 17 servers running with networking disabled, so a socket was the only way in. diff worked through URLs and through config files, and PostgreSQL output came from pg_dump.

Fixes #44

🤖 Generated with Claude Code

A server's `socket` setting, ?socket= in a URL, MySQL's ?unix_socket= or
libpq's ?host=<directory> connect through a Unix-domain socket instead of
TCP, for the diff and the migration runner alike. MySQL names the socket
file; PostgreSQL the directory holding it, and a .s.PGSQL.<port> file is
read as its directory and port. A MySQL server given only a socket needs no
host or port. The pg_dump renderer passes a socket directory as ?host=,
since it cannot stand where a host name goes in a URI.

A config file's `driver` now applies when --driver is not typed: the
option's own default overrode it, so `driver: pgsql` in a config file was
read as MySQL.

Fixes #44

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added mysql Related to Mysql php Pull requests that update php code postgres Related to Postgres question sqlite Related to Sqlite labels Nov 12, 2026
@sonarqubecloud

Copy link
Copy Markdown

@jasdeepkhalsa
jasdeepkhalsa merged commit 5027400 into master Nov 12, 2026
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mysql Related to Mysql php Pull requests that update php code postgres Related to Postgres question sqlite Related to Sqlite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A way to specify a non-standard socket?

1 participant