🐛 Make LoadReservedNameData fixture idempotent#1295
Conversation
Migration Version20260418120000 seeds the `postmaster` and `abuse` reserved names. The basic fixtures (loaded with --append by `make fixtures`) re-insert the same names, causing a duplicate-key violation on `reserved_names` and breaking local environment setup on any migrated DB. Skip reserved names that already exist before persisting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
Fixtures must not be idempotent. The idea is to prefill the system with a fixed set of data. If you need to reapply, you need to purge the database and start fresh. |
|
The docs say I should do |
|
The docs are wrong at this point. IMHO the fixtures are a static set for the beginning and nothing you should be able to re-apply. If we want to change that, we need to change all the fixtures to be idempotent. |
|
And we should keep postmaster in the fixtures. This should be a forbidden name to register. |
|
@0x46616c6b I feel we're misunderstanding each other. I have no prior setup. Then I do |
|
I found the root cause: We have a migration that adds abuse and postmaster to ReservedNames, so we only need to remove them from the fixtures, nothing more. |



Problem
make fixturesfails on any migrated database:Migration
Version20260418120000("Migrate postmaster aliases to settings and ensure reserved names exist") seeds thepostmasterandabusereserved names.LoadReservedNameData(groupbasic) insertsadmin, root, postmaster, abuse, webmaster. Sincemake fixturesloads with--append(no purge), the overlapping names collide → duplicate-key crash.Fix
LoadReservedNameData::loadnow skips names already present before persisting, keeping the fixture idempotent under--append.Verification
doctrine:fixtures:load --group=basic --appendsucceeds against a DB already seeded by the migrationreserved_namesends with exactly one row per name (admin, root, postmaster, abuse, webmaster)composer cs-fix(no changes),composer psalm(no errors),composer rector-check(OK)Found while setting up local env for #1293; unrelated to that change.
🤖 Generated with Claude Code