01 · Before and afterThe pattern
// before: client saw null, so it writes unconditionally
await db.account.update({ where: { id }, data: { timezone } });
// after: the database decides whether it's still empty
const { count } = await db.account.updateMany({ where: { id, timezone: null }, data: { timezone } });
if (count) track("timezone_auto_set");-- deprecating a column: keep it non-null for old readers
ALTER TABLE "Schedule" ALTER COLUMN "timezone" SET DEFAULT 'UTC'; -- not DROP NOT NULL02 · Run it on your appThe check
When you stop writing a column, will an older app instance still running during the deploy get null from it?
If the honest answer is no or not sure, this is worth a look before it reaches production.