Following last week's release which focused on Artisan, this week's Laravel v9.24 release introduces three new database commands we think you will love.
Artisan "db:show" Command
This new command gives you an overview of your database as a whole. When running the command you will see a summary of the database, including its type, connection details, number of open connections, and more.
Artisan "db:table" Command
A few weeks ago, Laravel introduced a model:show
command that allows you to get a quick overview of an Eloquent model. While this command is helpful, sometimes you may want to inspect the underlying database table instead.
The new db:table
command allows you to get a quick, valuable overview of an individual database table used by your application, including its size and number of rows. In addition, this command provdies a breakdown of every column along with its attributes and data type. Of course, all table indexes and foreign keys are summarized as well.
Artisan "db:monitor" Command
Much like the queue:monitor
command, the new db:monitor
command allows you to quickly see the number of open connections to your database, which is one indicator of the load it is currently under.
In addition, you may pass the --max
option to the command, which will dispatch a DatabaseBusy
event when the number of connections is greater than the --max
count that was specified. If no --max
option is provided, the DatabaseBusy
event will not be dispatched.