Is it possible to execute php artisan migrate
in a way to migrate all the tables but leave only a few migration files under database\migrations
?
The scenario is, our business requirement needs 2 DBs. So there are few migration files that explicitly mentions the 2nd DB. When I am creating another DB for PHPUnit, I don't need to run the migration files that are associated with the 2nd DB.
You can place any migrations you don't want run automatically in a subfolder. For example:
/database
/migrations
/db2
migration_3
migration_1
migration_2
Now when you run:
php artisan migrate
Only the migrations in the database/migrations
directory will be run (non-recursively, so the db2
directory will not be traversed), meaning only migration_1
and migration_2
will be run.
To run the migrations in the db2
directory separately you can use the --path
option like so:
php artisan migrate --path=/database/migrations/db2