Laravel Running migrations


Example

Once your migration is written, running it will apply the operations to your database.

php artisan migrate

If all went well, you'll see an output similar to the below:

Migrated: 2016_07_21_134310_add_last_logged_in_to_users_table

Laravel is clever enough to know when you're running migrations in the production environment. If it detects that you're performing a destructive migration (for example, one that removes a column from a table), the php artisan migrate command will ask you for confirmation. In continuous delivery environments this may not be wanted. In that case, use the --force flag to skip the confirmation:

php artisan migrate --force

If you've only just run migrations, you may be confused to see the presence of a migrations table in your database. This table is what Laravel uses to keep track of what migrations have already been run. When issuing the migrate command, Laravel will determine what migrations have yet to run, and then execute them in chronological order, and then update the migrations table to suit.

You should never manually edit the migrations table unless you absolutely know what you're doing. It's very easy to inadvertently leave your database in a broken state where your migrations will fail.