All articles Engineering

What a fresh install should look like

Correct on arrival, not correct after something repairs it.

Photo: Helpameout (CC BY-SA 3.0) / Wikimedia Commons

For months our installer produced a wrong catalogue that two migrations then corrected on first page load. The end state was right, so nothing appeared broken.

It was still wrong, and it is worth being precise about why.

The difference

A fresh install seeded prices from an old currency, key validity from an old policy, and features written as English sentences where the code expects catalogue keys. Then, on the first request, migrations converted the prices and rewrote the features.

The installed state was never the intended state. It was a state something else repaired.

Why that is not fine

The repair is a chain. Two migrations, in order, each guarded by its own marker. Break either and the install is silently wrong rather than loudly broken — and "silently wrong" here means a price list.

It hides a real bug. One of those migrations kept a map of what tiers should cost, keyed by plan *code* — so it fired on any matching row regardless of what that row held, including a fresh install already seeded correctly, knocking $19 back to $9. It only came out right because the *other* migration put it back.

Two bugs cancelling is not a working system. It is a working system until somebody touches either one.

Nobody can read it. Answering "what does a new install get?" required tracing three files and reasoning about execution order. That question should have a one-file answer.

The fix

Seed what the product actually sells. Make the conversion migration skip anything already in the target currency — a migration that converts naira to dollars has no business touching dollars. Add a test that reads the installer's own SQL and fails if it drifts from what the code expects.

Both paths verified end to end afterwards: a fresh install stays at the current prices, and an install still on the old ones converts and reprices to the same place.

The tell

If you cannot answer *what does a fresh install look like?* by reading one file, you do not know what your installer does.

We did not. We thought we did, because the result was correct, and a correct result is very good at hiding an incoherent process.

Start building

Lock a key to your domain in about five minutes.

Get started