Files
Mao NakamotoandClaude Sonnet 5 dbe2084bf9 fix(db): drop legacy trigger_set_timestamp trigger via Prisma migration
Any Postgres provisioned before 9449719 (which removed backend/db/init.sql
in favor of Prisma-only schema management) still carries a
trigger_set_timestamp() trigger created by that old init.sql. Its
pre-860a589 form references NEW.updated_at against the actual camelCase
updatedAt column, so it throws on every UPDATE to users/forms regardless
of Prisma's own @updatedAt handling at the app level (the DB trigger fires
independently of how the UPDATE was issued).

9449719 stopped new databases from ever getting this trigger, but did
nothing for ones that already had it - the roadmap's suggested fix
("run this SQL once by hand") never got applied. Ship it as a real
Prisma migration instead: DROP TRIGGER/FUNCTION IF EXISTS, which is a
no-op on databases that never had the trigger and clears it on ones
that did.

Verified against a disposable postgres:15-alpine container: fresh DB
applies cleanly; a DB seeded with the old buggy trigger reproduces the
exact `record "new" has no field "updated_at"` failure, and the new
migration's DROP statements fix it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-07 04:11:33 +00:00
..