content patches are not schema migrations
Prod's database only accepts connections from the host, so every code-side edit to live content ships as a one-shot patch that runs on deploy. The rule that makes it safe: a patch shares its row with the admin panel, so it has to be a transformation that no-ops rather than an end state that overwrites.
In July I banned em dashes from everything on this site, including the copy stored in the database. Three published posts already had them. Those em dashes were sitting in posts.excerpt and posts.body on a MySQL database that accepts connections from localhost only. On prod, MYSQL_HOST=localhost is not a convenience setting, it is the whole access model: no port to tunnel, no external client, no SQL session from my Mac.
So the fix had to travel the only path into that database I control, which is the deploy.
the seed is a lie
The obvious first idea is to edit the seed file and push. It does nothing. The blog repo seeds like this:
const existing = await db.select({ slug: postsTable.slug }).from(postsTable).limit(1);
if (existing.length === 0 && seedPosts.length > 0) {
await db.insert(postsTable).values(seedPosts.map(toRow));
}One row in the table and the seed never runs again. Seeds are for empty databases. Editing one and then refreshing prod, waiting for a change that is never coming, is a mistake you make exactly once.
What runs instead is 38 lines in src/core/db/content-patches.ts:
export async function applyContentPatches(db: Db, patches: ContentPatch[]): Promise<void> {
const [row] = await db.select().from(appSettings).where(eq(appSettings.id, KEY)).limit(1);
const applied = new Set(Array.isArray(row?.value) ? (row.value as string[]) : []);
for (const patch of patches) {
if (applied.has(patch.id)) continue;
await patch.apply(db);
applied.add(patch.id);
// record the id
}
}A patch is an id and an apply(db). The applied ids live in a single app_settings row under the key content_patches, and each feature's repo bootstrap runs its own list once per process: blog, projects, and the Roblox hub. Write the patch, push, the first request after deploy runs it, the ledger records the id, it never runs again.
That is a migration runner, and the resemblance is the trap.
the row has two authors
A schema migration owns what it touches. ALTER TABLE is a statement about structure, and nobody else is out there quietly renaming your columns overnight. Content rows are not like that. Every row a patch touches is also editable from /admin/content/blog or /admin/content/projects, by me, at any hour, with no coordination and no record in git. Code and the admin panel are two writers on the same row, and only one of them leaves a diff.
So a content patch cannot express a desired end state. A patch that says "this project's summary should read X" will eventually run against a row I improved by hand last week, and silently throw that away. Every patch has to be written as a transformation that survives having already happened, and survives somebody else having gotten there first.
In practice that comes out as two shapes. Insert-if-missing, for anything new:
for (const p of list) {
const [existing] = await db
.select({ slug: posts.slug })
.from(posts)
.where(eq(posts.slug, p.slug))
.limit(1);
if (!existing) await db.insert(posts).values(toRow(p));
}The April to July backfill shipped through that: 12 posts written from real project history, inserted only on databases that were seeded before those posts existed. Where the slug is already present, the patch does nothing to it.
And targeted swaps, for anything that changes:
const role = row.role === "Founder" ? "Cofounder" : row.role;
const summary = row.summary.replace("I founded it", "I cofounded it");That is the Pogi Games credit fix. I cofounded it, the project row said Founder. The patch changes the role only while the field still reads exactly Founder, and rewrites one sentence fragment by exact match. If I had already fixed either by hand, both operations are no-ops. A rename works the same way, firing only while the name still holds its launch value:
name: row.name === "Physics Lab Reports" ? "Physics" : row.name,The check I run on every patch now: picture it executing against a row somebody edited five minutes ago. If the answer is "their edit is gone", rewrite the patch.
The ledger is written after apply, not before, so a crash in between means the patch runs a second time. That is fine, because the shapes above are all idempotent on their own. The ledger saves work, it does not prevent damage. The patch body has to do that.
when overwriting is the point
One patch in the blog list breaks every rule above, which is why I do not treat merge-style as law.
On July 18 I published Style.it posts that were not true. Two were fabricated outright, and the launch post described an architecture the product never had. The correction shipped as 2026-07-18-style-it-truth:
await db
.delete(posts)
.where(inArray(posts.slug, ["agreeable-ai-is-useless", "the-approve-step-is-the-product"]));
await insertMissing(db, aiSeriesPosts);
await db
.update(posts)
.set({ title, excerpt, body, readingMinutes, updatedAt })
.where(eq(posts.slug, "building-style-it"));A hard delete, then an unconditional overwrite of a published body. Merge-style would have been the wrong instinct here. Destroying what was in those rows was the entire purpose.
So the dividing line is not "content patches merge". It is that a patch which adds something must never destroy an edit, and a patch whose reason for existing is a correction must be allowed to. Ask what the row's other author would want if they were reading over your shoulder, then write that.
Nineteen patch ids across the three lists now: 10 in projects, 5 in blog, 4 in the Roblox hub. Every one of them changed live content without a database credential, a tunnel, or a SQL session.