<?php

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

class CreateStepsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('steps', function (Blueprint $table) {
            $table->id();
            $table->Morphs('owner');
            $table->bigInteger('appointee_id')->unsigned()->index();
            $table->string('obligation_hash_id',200)->nullable();
            $table->string('reference');
            $table->integer('primary')->default(false);
            $table->decimal('sequence', 4, 2);
            $table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION);
            $table->date('complete_date')->nullable();
            $table->softDeletes();
            $table->timestamps();

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

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