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

Baadier's avatar

What happens when you run migrations on your production server?

I'm getting ready to deploy my first Laravel site to production in the next week or two and I had a question with regards to migrations which is probably silly but I havent really got my head round it.

Does my database get wiped when I run the migrations on my production server and then re-created based on the migrations ie I end up with the same structure but sans any data that was through user entry on the site?

0 likes
7 replies
alenn's avatar

Migration doesn't know if it's being run on production or local environment, so whatever action you see on local environment you'll see it in production.

Baadier's avatar

Thanks for the reply @alenn

What solutions are people using for preserving data if the tables are wiped or am I misunderstanding?

ltrain's avatar
ltrain
Best Answer
Level 5

The only migrations run are ones that have not been run before for that database. Laravel keeps track of the ones that have been run in the migrations table that it makes.

The only reason data/tables would be deleted is if you ran artisan migrate:rollback or artisan migrate:reset, which I do not recommend doing on a production database. Ever. Typically it not realistic to revert migrations in that type of environment.

1 like
jekinney's avatar

php artisan migrate will as @ltrain stated add to your data base

php artisan migrate:refresh will delete all tables and re-migrate fresh tables

bashy's avatar

If you're doing a new site on production but you have data to go into the table, you will migrate first, then import.

Please or to participate in this conversation.