dimanche 17 juillet 2016

Laravel :: Best way to update foreign key

I have this migration file

Schema::create('table_one', function(Blueprint $table) 
{ 
    $table->increments('id'); 
    $table->string('name'); 
    $table->integer('table_two_id')->unsigned(); 
    $table->foreign('table_two_id')->references('id')->on('table_two'); 
    $table->timestamps(); 
});

and I want to update to make it ->onDelete('cascade');

$table->foreign('table_two_id')->references('id')->on('table_two')->onDelete('cascade');

What is the best way to do this?

Is there something like ->change();

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire