Invental/Review lessons/Code that silently does the wrong thing

Code that silently does the wrong thing

An ORM default does not change the database

Changing a default in your ORM schema changes your types, not your database; and a default that pins a fast-moving build tool is a product decision, not a version bump.

01 · Before and afterThe pattern

TypeScript
// schema.ts: this alone changes nothing on an existing database
version: text("version").default("2.0.0"),
// the live default only moves with a migration:
// ALTER TABLE app ALTER COLUMN version SET DEFAULT '2.0.0';
// or: keep the stable default and offer newer versions as an opt-in choice

02 · Run it on your appThe check

When you change a column default in your ORM schema, do you ship the migration that changes it in the database too?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.