Home > other >  I need to update an existing migration by adding only onDelete('cascade');
I need to update an existing migration by adding only onDelete('cascade');

Time:08-01

I need your help. Days ago I created the following migration:

2022_07_28_144638_create_projects_table.php

Obviously it is not the last because I have created several. Now I have added onDelete ('cascade') on the following line:

$table-> foreign('client_id') -> references('id') -> on('clients') -> onDelete('cascade');

so since it was added after now I have to do a migrate on the same migration again.

I need to figure out how to do this. I'm new to Laravel.

CodePudding user response:

If you are in the local environment, you should use the following command.

php artisan migrate:rollback

then update migration code

$table->foreignId('client_id')->references('id')->constrained('clients')->cascadeOnDelete();

then

php artisan migrate

CodePudding user response:

Try using this command:

php artisan make:migration create_flights_table

and if there are no errors, run this command:

php artisan migrate
  • Related