Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

x1m's avatar
Level 3

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?

Had a minor issue that requires a refresh sadly.

0 likes
3 replies
Screenbeetle's avatar

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).

I'll be interested to know what you end up doing.

1 like
ejdelmonico's avatar
Level 53

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.

1 like
x1m's avatar
Level 3

Thanks for the answers guys!

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.

Thanks again for giving good tips!

Please or to participate in this conversation.