<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateContractTemplateObligationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('contract_template_obligations', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unsigned()->nullable();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->bigInteger('contract_template_id')->unsigned()->nullable();
            $table->foreign('contract_template_id')->references('id')->on('contract_templates')->onDelete('cascade');
            $table->string('name')->nullable();
            $table->float('sequence', 4, 2)->nullable();
            $table->string('reference')->nullable();
            $table->json('content')->nullable();
            $table->integer('must_complete')->nullable()->default(1);
            $table->integer('must_accept')->nullable()->default(1);
            $table->integer('complete_day_range')->nullable()->default(1);
            $table->integer('type')->nullable()->default(1);
            $table->integer('status')->nullable()->default(1);
            $table->timestamps();
        });
    }

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