by jpollock · 12y ago · 0 comments
In the order presented:
1) Run migration
2) Apply trigger
There will be a point in time where the migration has been done and the trigger hasn't been applied.
Even sneakier, if the trigger is applied in code and not in the database, there will be period in time where some of the code is running the trigger and some isn't.
The trigger needs to be in production and executing prior to the backfill running.
I'm also loathe to rely on "triggers" in application model logic. I've seen too many platforms where the operations engineers interact directly with the database, resulting in required logic not executing.
When tricky concurrency is involved, using the built-in tools offered by the database is the safest approach.
Often, it's also the easiest and most performant.