Add supplier linking

This commit is contained in:
Deon George
2022-08-07 12:17:20 +10:00
parent a1fd36aa6f
commit 2722c92bcf
10 changed files with 339 additions and 11 deletions

View File

@@ -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');
}
};