Laravel Migrate Specific File(s) from Migrations
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Managing databases using modern PHP frameworks like Laravel has made the process more efficient and effective, but sometimes developers may find themselves in situations where they want to migrate only certain migration files. In this comprehensive guide, we will explore various techniques and approaches for precisely handling migrations within your Laravel application.
Understanding Migrations
Migrations provide a structured approach for managing database changes in Laravel applications. They are stored as separate PHP files that follow a specific format, allowing developers to define and manage the schema of their database easily. The default migration folder is located at app/Database/Migrations.
Migrating All Database Tables
To begin with, let us understand the standard Laravel command used for migrating all the tables in your database: php artisan migrate:refresh. This command essentially runs each migration file sequentially, starting from the first one and moving to the last. Although this is useful in many cases, it might not be suitable when you want to modify a specific table without affecting others.
Migrating Specific Tables
Laravel provides an option for migrating only specific tables by using the --path argument. You can pass the exact path of the desired migration files and Laravel will only execute migrations from those specified paths.
php artisan migrate --path=database/migrations/2019_05_28_104736_create_table_users.php
php artisan migrate --path=database/migrations/2019_05_28_104736_create_table_users.php,database/migrations/2019_05_29_122521_add_column_address_to_users.php
Note: You can use commas to specify multiple paths if needed.
Migrating Specific Fields within a Table
There might be times when you just want to modify a particular field within an existing table. For this, you would need to execute the specific migration that updates the concerned column. This can be done by running the following command:
php artisan migrate:rollback
php artisan migrate:refresh
php artisan migrate --path=database/migrations/2019_05_28_104736_create_table_users.php
Note: This process will first roll back the database to its original state and then run the specified migration file, which will update the field you wish to modify.
Utilizing Artisan Commands for Precision
Besides the default commands provided by Laravel, there are several artisan commands that can help with custom migrations:
1.php artisan make:migration create_users_table --create=users: This command generates a migration file for creating a new table called 'users'. You can replace 'users' with the desired table name as per your requirement.
Note: The --create option is used to specify the name of the table being created.
php artisan make:migration add_column_address_to_users_table: This command generates a migration file for adding an 'address' column to the 'users' table. If you already have tables and just want to add columns, this command will create the necessary migrations for you.
Note: The name of the table should be specified in lower case with underscores instead of spaces.
php artisan make:migration drop_column_address_from_users_table: This command generates a migration file for removing the 'address' column from the 'users' table. It is useful when you want to delete columns without affecting other tables or fields.
Note: You can change 'drop' with 'rename' if you need to rename the existing column.