database/migrations/2015_11_10_225902_db_foreign_key.php
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.
        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        // Database Relationship Extras
        Schema::create(
            'db_relationship_extras',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->integer('service_id')->unsigned();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->string('table');
                $t->string('relationship');
                $t->string('alias')->nullable();
                $t->string('label')->nullable();
                $t->text('description')->nullable();
                $t->boolean('always_fetch')->default(0);
                $t->boolean('flatten')->default(0);
                $t->boolean('flatten_drop_prefix')->default(0);
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );
    }
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.
        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        // Database Relationship Extras
        Schema::create(
            'db_relationship_extras',
            function (Blueprint $t) use ($onDelete){
                $t->increments('id');
                $t->integer('service_id')->unsigned();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->string('table');
                $t->string('relationship');
                $t->string('alias')->nullable();
                $t->string('label')->nullable();
                $t->text('description')->nullable();
                $t->boolean('always_fetch')->default(0);
                $t->boolean('flatten')->default(0);
                $t->boolean('flatten_drop_prefix')->default(0);
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            }
        );
    }
Run the migrations.

@return void