/** * Adds a `version` column to saved_encounters for optimistic locking. * Concurrent edits previously clobbered each other silently (last * write wins). The route compares the caller's known version against * the row's current version and rejects with 409 when they diverge. */ exports.up = (pgm) => { pgm.addColumn('saved_encounters', { version: { type: 'integer', notNull: true, default: 1 } }); }; exports.down = (pgm) => { pgm.dropColumn('saved_encounters', 'version'); };