How do you stop your live database and your code from drifting apart?
I’m a solo founder building with AI tools. This week I found out the emoji reactions in my app had never been saved for anyone.
The cause was simple. The code wrote to a column called reaction, but the live database column had a different name. The app still showed the emoji as highlighted, and nothing was stored. The count of saved reactions was zero, and no error showed up anywhere.
The fix was small: a migration that renames the column only if the old name exists, and a check so the app now says “not saved” when no row actually updates.
What I still don’t have is a habit that stops this from happening again. If you build on Supabase or any hosted database, how do you keep what’s live and what’s in your code in sync? Do you check it before every release, or just wait for a bug?
Replies
Same stack, same problem. On my project (LLMPvP, also Supabase) production fell more than a week
behind main twice: migrations tested locally and never pushed. Another time, hotfixes went straight
to production during a security incident, and the live grants stopped matching the schema files.
Habits that stuck:
1. Schema lives in declarative files (supabase/schemas/*.sql). Every change goes file > supabase db
diff -f name > read the generated SQL > apply. After applying, supabase db diff has to say "No
schema changes found".
2. A migration isn't done until it's applied to local and production in the same task. That rule
alone would have prevented both gaps.
3. If you fix production by hand, turn it into a migration file the same day and make it safe to
re-run. Your "rename only if the old name exists" is exactly that.
4. Before a push, compare local and remote versions (supabase migration list). In one cleanup I had
32 migrations with identical SQL but different version numbers. A blind db push would have failed
on the first one.
Keep the "not saved when no row updates" check everywhere. A write that silently touches zero rows
is the worst kind of bug because nothing ever looks broken.