While working on a product at VentureCraft, I wanted to make sure that there was no way I could accidentally screw myself over by running something like
migrate:refresh in production. I put up a teaser on twitter which got some good attention so I thought I’d share the nasty code I used to achieve this.
At this stage, all I’m doing is adding a snippet of code to the top of my
app/artisan.php file, which performs the check. At a later stage I planned on moving this to a package so I can use it in other projects, however I received the following tweet from Taylor which hopefully will make that redundant and he’ll just build it into the core (a touch more elegantly I’m sure):
@duellsy i should probably just bake that into the framework honestly— Taylor Otwell 🏜 (@taylorotwell) April 4, 2014
What’s more, in the package I’d planned on allowing to pick and choose which commands are protected in which environment based on a config file, the following hopefully will take care of that too:
@duellsy at least for those destructive type actions on migrations— Taylor Otwell 🏜 (@taylorotwell) April 4, 2014
Stoked to see that this has indeed been added into the core, as a trait you can add to your own commands