👋 Hey friends,

Here’s what I’ve got in store for you this week:

  • Another snippet from The Backend Lowdown

  • Upcoming series: DB monitoring tips

  • Recent AI News

Let’s get into it 👇

Every newsletter will include a snippet from my book in progress, The Backend Lowdown, available for $5 right now on Gumroad!

Get The Backend Lowdown →

Observing and Deploying Migrations Safely

Once you've written a migration and planned the rollout, your job isn't over. A migration that works in staging can still misbehave in production - especially under load or with unexpected data.

To minimize risk, treat schema changes like any other deploy: something to observe, verify, and potentially roll back. Here's how to do that effectively.

Set a Statement Timeout

Always set a statement_timeout when running migrations in production. This prevents a runaway or blocking migration from hanging indefinitely and causing collateral damage (e.g. stalled deploys, locked tables, or frozen workers).

PostgreSQL example:

SET statement_timeout = '15s';

In Rails, you can wrap your migration logic like this:

def up
  execute "SET statement_timeout = '15s';"
  # ... rest of the migration
end

This forces the migration to fail fast if it takes longer than expected - which is often better than letting it quietly lock things for minutes.

Attempt to Make Migrations Reversible

Whenever possible, write migrations that are reversible - so you (or a future teammate) can undo them safely.

ActiveRecord supports reversible migrations automatically in many cases:

def change
  add_column :users, :status, :string
end

But if your migration involves raw SQL or irreversible actions (like drop_table or destructive execute calls), use the up/down form and at least attempt to write a rollback:

def up
  remove_column :users, :status
end

def down
  add_column :users, :status, :string
end

Even if it's not a perfect reversal, making a best-effort rollback is better than leaving someone stranded.

Upcoming Series: DB Monitoring

Recently I ran into an interesting scenario which turned out to be fixing some write contention in a write-heavy application. Resolving this problem required knowing where to look and how to interpret some specific charts. After working through that, I thought it would be an awesome and informative series so the next few posts I’ll be explaining some very useful charts you’ll find in AWS CloudWatch (or DataDog / your favorite APM) and how you can use these to help identify potential issues like this. Stay tuned!

AI News

Claude + Codex are now available in public preview on GitHub (Agent HQ). If you’ve got Copilot Pro+ or Copilot Enterprise, you can pick an agent per task and one of the slick workflows is assigning an issue to an agent so it starts work and opens a draft PR for you to review. Source

Anthropic also shipped Claude Opus 4.6 with a 1M-token context window (beta). This is the kind of jump that makes “point an LLM at a big chunk of a repo / incident timeline” actually viable.Source

That’s a wrap for this week. If something here made your day smoother, feel free to reply and tell me about it. And if you think a friend or teammate would enjoy this too, I’d be grateful if you shared it with them.

Until next time,
Steven

Keep Reading