Forge: Forge Script able to run php artisan migrate:refresh?
Hi,
I am running a production app via Forge, but i need to do php artisan migrate:refresh. If i make a backup from the database, would this do any harm? Except wiping out current data that is in DB?
This would wipe all data and rebuild your database from scratch.
Have you thought about creating a new db - correctly migrated and seeded - and simply swapping over to that?
If not then I guess you'd need to have a quick way to reseed after running migrate:refresh. If you export data from your current db you could manually import it back after refreshing (that or create seeds).
You can do a dump of the data and do a quick comparison to make sure it is correct before refreshing the DB. As you are aware, running that artisan command will wipe everything.
What I have done in the past is freeze everything and make a DB copy to local and run the refresh and restore on the local copy. This way, I can check for any unforeseen issues before I wipe everything on production.
I have made an SQL dump on local development (vagrant/homestead) with MySQL Workbench and re-dumped it back after i did migrate:refresh. This worked perfectly!
Inside Forge i edited the deployment script to migrate:refresh instead of migrate for just one deployment. Before deploy i made a dump and re inserted this after the refresh!
No problems so far, but the database is not that complicated. Just a lot of data.