Cheapest correct fix is optimistic locking: add a version int column, send it with the save, and update where id = ? and version = ?, incrementing version. Zero rows updated means someone else saved first; show 'this lesson changed, reload'. Real-time co-editing (CRDTs) is a different product.
Question
How do I let two teachers edit the same lesson without overwriting each other?
Two people open a lesson, both save, the second save wins and the first person's changes vanish.
What I’ve tried
Added a 'last saved by' label. Doesn't prevent it.
2 answers
Marked as helpful by the asker
Version column is in. A colleague and I tested it on purpose, second save gets the reload message. Nobody loses work now. dana_ships
Nice extra on top of the version check: Supabase Realtime presence on a channel per lesson, so the editor shows "Ana is also editing" as soon as a second teacher opens it. Most conflicts never happen once people can see each other. Keep the version check as the actual safety net; presence is a courtesy, not a lock.
The teachers would love that. Putting it on the list. dana_ships