If you are working with multiple database connections in your Laravel project. And you are looking to run migrations for specific database connection.


php artisan migrate --database=mysql

If you have do specify the path along with the database you can do so by following


php artisan migrate --database=mysql --path=/database/migrations/mysqlmigrations

Here's what this command does

php artisan migrate is a Laravel command that runs all outstanding migrations that have not yet been run. In other words, it applies any database schema changes that have been defined in migration files to the database.

--database=mysql specifies that we want to use the mysql database connection defined in the config/database.php file. Laravel supports multiple database connections, so we need to specify which one we want to use for the migration.

--path=/database/migrations/mysqlmigrations specifies the path to the directory that contains the migration files we want to apply. In this case, the migration files are located in the /database/migrations/mysqlmigrations directory. Laravel will only apply the migration files in this directory.

So when you run this command, Laravel will look for the migration files in the /database/migrations/mysqlmigrations directory and apply them to the database using the mysql database connection. Any changes defined in these migration files will be applied to the database schema.

Comments