Running one specific Laravel migration (single file)
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: Running One Specific Laravel Migration (Single File)
Introduction: Managing database migrations is an important part of the Laravel development process. Sometimes, it may be necessary to run only one specific migration file out of multiple available ones in a project. In this blog post, we'll discuss different methods for running a single Laravel migration using the
php artisan migrate command.
1. Accessing Migration Files Directly: To run an individual migration, first locate its filename within your Laravel application's migrations directory. Typically, this would be database/migrations. Open a terminal or command prompt and navigate to the appropriate folder.
cd /path/to/laravel_project/database/migrations
php artisan migrate command but add the name of the specific migration file with a dot prefix to run it individually. Replace migration_file_name with the actual filename of the desired migration:
php artisan migrate --path=migrations/migration_file_name
--path flag for Laravel's php artisan migrate:
php artisan migrate --path=migrations/migration_file_name_1,migration_file_name_2
MIGRATIONS_TABLE to store the list of migrations for your project. Every time Laravel runs this command, it'll use that environment variable to know which migrations files should be executed. This method offers more flexibility and is useful when running multiple migrations or sharing the migration environment with other developers without exposing the specific filenames.
export MIGRATIONS_TABLE="migration_file_name_1,migration_file_name_2"
app/Console/Commands directory with a name specific to this command (e.g., SingleMigrationCommand).
b. Define a namespace at the top of the class, if needed, and extend Laravel's ConsoleCommand class.
c. Add the signature for your custom command, replacing migration_file_name with the actual filename:
protected $signature = 'single-migrate:run {--force : Run the migration forcefully}';
registerCommands() method of Laravel's Console/Kernel.php class:
$this->commands[] = new SingleMigrationCommand();
php artisan single-migrate:run --force