Migrations
All migration files & changes to the database SHOULD be updated in the migration files. Migrations are a crucial part of the automated testing for the system.
Up
Write up() methods for deploying automated changes to the database.
Down
Write down() methods because:
- It should be possible to roll back failed releases.
- Developer experience: it simplifies switching between branches.
Procedures & Views
Keep all queries (Eloquent or raw) in the repositories of the relevant module. Do NOT create database views or stored procedures for functionality in the database layer. This makes it very difficult to troubleshoot and creates magic in the system. When you need to modify it you also need access to the database, whereas if it lived in code you could just modify it and deploy.
When you really need to create a database view and you are certain it is the best option, please chat to a team lead. It is definitely beneficial for reporting purposes.
Read More:
