Add migrations to handle cascade deletions for servers and users

This commit is contained in:
Dane Everitt 2017-07-08 15:51:13 -05:00
parent 2588c25b0b
commit 8953f83f87
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 130 additions and 1 deletions

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class SetAllocationToReferenceNullOnServerDelete extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('allocations', function (Blueprint $table) {
$table->dropForeign(['server_id']);
$table->foreign('server_id')->references('id')->on('servers')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('allocations', function (Blueprint $table) {
$table->dropForeign(['server_id']);
$table->foreign('server_id')->references('id')->on('servers');
});
}
}