fixed warehouses FK relation error

This commit is contained in:
Zain Fauzan Rofie Azizi
2018-06-26 16:31:13 +08:00
parent f6222c6253
commit 4e0eb3528d
3 changed files with 74 additions and 0 deletions
@@ -21,6 +21,7 @@ class AddForeignKeyToWarehousesTable extends Migration
->onDelete('cascade');
});
}
/**
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropComIdForWarehousesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('warehouses', function (Blueprint $table) {
$table->dropForeign(['com_id']);
$table->dropColumn('com_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('warehouses', function (Blueprint $table) {
//
});
}
}
@@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeReferenceIdForWarehousesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('warehouses', function (Blueprint $table) {
$table->unsignedInteger('com_id');//FK wrn id
$table->foreign('com_id')
->references('id')->on('companies')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('warehouses', function (Blueprint $table) {
//
});
}
}