Add supplier linking
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('supplier_details', function (Blueprint $table) {
|
||||
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
|
||||
});
|
||||
|
||||
Schema::create('supplier_user', function (Blueprint $table) {
|
||||
$table->integer('site_id')->unsigned();
|
||||
$table->integer('supplier_id')->unsigned();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('id');
|
||||
$table->dateTime('created_at');
|
||||
|
||||
$table->unique(['supplier_id','user_id']);
|
||||
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
|
||||
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('supplier_details', function (Blueprint $table) {
|
||||
$table->dropForeign(['supplier_id']);
|
||||
});
|
||||
|
||||
Schema::dropIfExists('supplier_user');
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user