1 | initial version |
You can migrate a particular file by using the following command in your terminal:
php artisan migrate --path=/database/migrations/filename.php
Replace filename.php
with the name of the migration file you want to migrate. This will run only the migration file you specified.
Alternatively, you can also specify the file name in the up()
method of your migration file. For example:
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamps();
});
// Add this line to run the migration file only when this method is called
DB::statement(file_get_contents(__DIR__.'/filename.sql'));
}
In this case, the migration file filename.sql
will only run when the up()
method is called.