Migrate Codex model to the repository design pattern