I have a migration file in a Laravel project that sits on a slightly-older branch. In newer branches, newer migrations have been created and ran in production. I have ran the migration in my local environment, but in no other environment.
What will happen if I need to push this migration to the master branch, then to production? My assumption is that it will just not run since a newer migration has run, but that is an assumption.
What is the best way to handle something like this? I could not find anything clear in the laravel documentation for Laravel 5.6.
Advertisement
Answer
My assumption is that it will just not run since a newer migration has run, but that is an assumption.
Laravel tracks which migrations it has run in the database’s migrations
table. If a migration is in the directory and hasn’t been run before, it will get applied next time artisan migrate
is run, regardless of the fact that “newer” migrations have already been run. The migration code is not inherently aware of dates; it’s running the migrations in filename order, as you can see in the relevant code.