Is your feature request related to a problem? Please describe.
Checking the uniqueness of a field in code is not performant, and doesn't work in a multithreaded system.
As the select and insert are done outside of a transactional context, there is no guarantee that the database is in the same state when the member is inserted as how it was when the constraint was checked.
Also, checking the uniqueness requires a round trip to the db, which can be avoided.
Describe the solution you'd like
Determine the uniqueness by putting a constraint on the db, and catch the non-unique exception.
Describe alternatives you've considered
Keep as-is, as concurrency issue is theoretical. Performance issue is real though.
Is your feature request related to a problem? Please describe. Checking the uniqueness of a field in code is not performant, and doesn't work in a multithreaded system. As the select and insert are done outside of a transactional context, there is no guarantee that the database is in the same state when the member is inserted as how it was when the constraint was checked. Also, checking the uniqueness requires a round trip to the db, which can be avoided.
Describe the solution you'd like Determine the uniqueness by putting a constraint on the db, and catch the non-unique exception.
Describe alternatives you've considered Keep as-is, as concurrency issue is theoretical. Performance issue is real though.
Additional context