<?php

use App\Classes\ValueObjects\Constants\RelationStatus;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateCompanyConnectionsTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_connections', function (Blueprint $table) {
            $table->id();
            $table->foreignId('module_one');
            $table->foreignId('module_two');
            $table->text('marking');
            $table->integer('status')->default(RelationStatus::PENDING);
            $table->foreignId('instigator')->comment('entity that is responsible for current status');
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('module_one')->references('id')->on('company_modules');
            $table->foreign('module_two')->references('id')->on('company_modules');

            $table->foreign('instigator')->references('id')->on('company_modules');


        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('company_connections');
    }
}
