Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 1 year ago.
0

I need to add a new table to my database but realised if i run migrations again it will need to rollback and delete everything to be able to run them again,

No it does not. unless you edited your old migrations you already ran on the server, which will change the order of how changes to the db are applied.

Migrations are applied to the database sequentially. So let's say in migration1 you create a table with 4 fields: then ran artisan migrate. And in migration2 you added an email field. and in the 3rd you changed the field email to email_address, when you run artisan migrate these migrations are applied one by one and if you have written the proper rollback statements the db should roll back correctly.

If more than one migration file was executed on the single artisan migrate command both of them will rollback once you run artisan rollback.

0

@GoodBytesUK - On standard machines without a deployment script running php artisan migrate will only run migrations which haven't been run yet. Basiaclly, it will run migration files which are not in the database table called migrations of your server.

However, I find that with using Envoy, it always deletes the existing migrations which is great for development deploys but not good for production. Does anyone know how this can be changed. I simply have a hood to run migrations and then seed but it does roll them back before hand without me instructing so?

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.