refactor active_record/adapter