retry appearance creation transaction on deadlock

If a transaction fails due to a deadlock, we'll retry it a maximum of 2 times.

[#72087884]
refactor appearance creation to a single method

We had two instances where we check if a user has X number of unanswered
appearances and if not we'll create one. This change just moves those two
instances to a single method that gets called.

[#72087884]
clean up create_or_find_next_appearance

* Only return an appearance. Caller can get prompt from the appearance.
* Consolidate to single raise in rescue block.
* Add clarifying documentation.

[#72087884]
further simplify get_first_unanswered_appearance

[#72087884]
Merge branch 'deadlock-retries'
Merge branch 'master' into record-prompt-algo
Switch to storing JSON in algorithm column.

This allows us to support arbitrary data structures to support any data like
parameters used for the algorithm or anything else we might want to store.