Vapor: are you using the right database?

Laravel Vapor is amazing.

But despite all its nice bells and whistles, human error can always find its way in.

On one of my projects, I mixed up some environment settings and connected to the wrong database. Ouch! Seems I’m not a robot after all.

Luckily, I was only overwriting old dummy data…

Nevertheless, I wrote a little command that helps me prevent this from happening again. It’s a simple check I’ve now added as the first build step on each Vapor deployment:

    - 'php artisan ensure:database:is staging'
    - '<other deploy steps here...>'

Here is the command, enjoy!

(Header photo by Jan Antonin Kolar)