How to write this in less possible code?

String.to_existing_atom/1 should work with the atoms used in the ecto schema since they were already created for ecto structs.