Asking which you should use is an opinion-based question, which isn't permitted on StackOverflow. We don't know what you should do. Each of these patterns has their own trade-offs.
To start you on your path for that answer, I recommend searching the web for "schema-first" vs "code-only" (sometimes "code-first") blog posts. Your first example is "code-only", and your second example is "schema-first"