Swap MySQL for PostgreSQL 18 #9
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/postgres-migration-pr4-2988a9"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #4 by making it moot: instead of bumping the
mysqlimage from 8.4 to26.7, this moves the example app to PostgreSQL 18.
Rebased onto #7 (
Store names in a Doctrine entity, seed via migration), whichlanded while this was open — the original raw-PDO version of this change is
gone, and the swap now happens in the DBAL config and the seed migration.
Changes
mysql:8.4→postgres:18.MYSQL_*env vars becomePOSTGRES_*(no separate root password needed), the healthcheck becomespg_isready -U app -d app, and the data volume moves to/var/lib/postgresql— thepostgres:18image placesPGDATAat/var/lib/postgresql/18/docker, so that's the mount point that persists.driver: pdo_pgsql, andcharsetgoes fromutf8mb4toutf8.CREATE TABLEwas MySQL-only.INT AUTO_INCREMENTbecomesINT GENERATED BY DEFAULT AS IDENTITY(what DBAL 4 emits for a#[ORM\GeneratedValue]integer id on PostgreSQL) and the
DEFAULT CHARACTER SET utf8mb4clause isdropped. The 26 seed INSERTs and
down()are unchanged.ext-pdo_mysql→ext-pdo_pgsql. Thematthewbaggett/php:8.5base image already shipspdo_pgsql, so theDockerfile is untouched.
dbimage.src/Entity/Name.phpandsrc/Controller/NameController.phpneeded no changes— the ORM abstracts the difference.
Two things worth a reviewer's attention
This rewrites an applied migration in place. That is normally the wrong
move. It's justified here because swapping the database engine means every
deployment starts from an empty PostgreSQL volume regardless, and a follow-up
migration could not repair the first one's MySQL-only DDL. Say the word if you
would rather have a fresh migration and this one left as history.
It also bumps
symfony/consolev8.1.1 → v8.1.2, which has nothing to do withPostgreSQL.
mainis currently broken:framework-bundlev8.1.2 declaresconflict: symfony/console <8.1.2, but the lock pins console at v8.1.1, socomposer install— and thereforedocker build— fails on a clean checkoutof
maintoday. Nothing could be verified without fixing it. Happy to split itinto its own PR if you'd prefer that landed separately.
Verification
Clean
docker compose down -v && docker compose up --build:dbhealthy onPostgreSQL 18.4 (Debian 18.4-1.pgdg13+1)sv-fixer.dinit hook runs the migration before nginx starts:1 migrations executed, 27 sql queriesdoctrine:schema:validate→ mapping correct, database in sync with themapping files
id = 27after the26 seeded rows)
doctrine:migrations:migrate firstrolls back cleanly, and migrating upagain re-seeds
GET /returns varying names (Julia, Charlie, Rachel, Quentin,Bob, Fiona…), no PHP errors
🤖 Generated with Claude Code
335a55997dtob28fb65cfe