If a migration is canceled, temporary databases will be orphaned. This problem should be pretty rare.
Temp db factories should clean up (some) orphaned databases each time they create a new database. This will ensure that # of orphaned temporary databases inevitably reaches 0.
Cleanup safety checks:
Make sure temp database matches expected name
Make sure metadata table is present
Attempt to validate the database contains no data
Additional thought:
It might be worth splitting the context in the temp database cleanup code and giving it a strict timeout to reduce the likelihood a temporary database becomes orphaned.
If a migration is canceled, temporary databases will be orphaned. This problem should be pretty rare.
Temp db factories should clean up (some) orphaned databases each time they create a new database. This will ensure that # of orphaned temporary databases inevitably reaches 0.
Cleanup safety checks:
Additional thought: It might be worth splitting the context in the temp database cleanup code and giving it a strict timeout to reduce the likelihood a temporary database becomes orphaned.