<?php

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

class CreateCompanyConnectionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_connections', function (Blueprint $table) {
            $table->id();
            $table->foreignId('inviter_id')->unsigned();
            $table->foreignId('invitee_id')->unsigned();
            $table->string('inviter_reference');
            $table->string('invitee_reference');
            $table->integer('status')->default(ApprovalStatus::PENDING_VERIFICATION);
            $table->softDeletes();
            $table->timestamps();

            $table->foreign('inviter_id')->references('id')->on('company_modules');
            $table->foreign('invitee_id')->references('id')->on('company_modules');
        });
    }

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