Question

Should I let Cursor write my database migrations?

Solved · 14 views · asked by ines_data · edited

Cursor happily generates migration files. Twice it generated one that dropped a column with data. I caught it, but barely.

What I’ve tried

Now I read every migration line by line. Slow.

Comment

2 answers

Marked as helpful by the asker
olu_backend · edited

Let it write them, never let it run them unattended. Three guardrails that cost nothing:

  1. DROP and ALTER ... TYPE require a comment explaining why, enforced by a tiny CI grep.
  2. Every migration runs against a copy of production first (pg_dump → local → migrate → smoke test).
  3. Ask Cursor for the down migration too. If it cannot write the down, the up is destructive.

Reading migrations is the one place where slow is correct.

Comment
mira_dev · edited

And separate 'expand' from 'contract': add the new column in one deploy, drop the old one a week later. Then a wrong drop is never same-day.

Comment