refactor reset_primary_key and change !blank? to present? in get_primary_key