Hi read all the included documentation here in https://laravel.com/docs/5.4/migrations.
Is there a way on how to migrate a certain migration file (1 migration only), cause right now every time there is a change I use php artisan migrate:refresh
and all fields are getting reset.
To run the specific migration in Laravel, you need to use --path option with the php artisan migrate command. Let's take a simple example, we have '2019_12_04_131405_create_payments_table. php' migration in the database/migrations directory and we would like to run this migration.
If you want to empty all table's data from database then runphp artisan migrate:refresh command.
First you should create one migration
file for your table like:
public function up() { Schema::create('test', function (Blueprint $table) { $table->increments('id'); $table->string('fname',255); $table->string('lname',255); $table->rememberToken(); $table->timestamps(); }); }
After create test folder in migrations folder then newly created migration moved/copied in test folder and run below command in your terminal/cmd like:
php artisan migrate --path=/database/migrations/test/
you should add the path to your migration file to refresh just this table and run
php artisan migrate:refresh --path=/database/migrations/fileName.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With