Have Package automatically run its Migrations when being installed or updated? Is it possible to do this? I want to take as much burden off of the user for the setup process, and especially for updating the package.
I envision the package running its migrations then seeders when installing it via composer. Any suggestions on how to do that?
Hi @mikebronner , edit your package composer.json file and you can find something as follow in the Laravel composer.json included:
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan route:scan",
"php artisan event:scan",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
The scripts are commands that you could run in the install, update or another.
Creating your custom comand or running your php artisan migrate custom command you should get it.
Hope it helps you.
Hi @codeatbusiness :) Thanks again. Yes, I have been playing with that, and think it works ... but have not gotten far enough to test it yet (my package is still in workbench -- which is also why I haven't updated the post yet). If it does end up working, I'll be sure to mark your answer, though. :)
Please sign in or create an account to participate in this conversation.