<?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::create('contracts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedTinyInteger('province_id')->index('province_foroign_key');
            $table->string('province_fa');
            $table->integer('office_id');
            $table->string('office_fa');
            $table->string('title');
            $table->integer('status_id');
            $table->string('status_fa');
            $table->string('contract_date');
            $table->string('contract_mojavez');
            $table->string('contract_mojavez_fa');
            $table->string('contract_mojavez_data_meli')->nullable();
            $table->string('contract_mojavez_data_setad')->nullable();
            $table->string('contract_tarh')->nullable();
            $table->boolean('national_credit_license')->nullable();
            $table->string('contract_credit_national')->nullable();
            $table->boolean('province_credit_license')->nullable();
            $table->string('contract_credit_province')->nullable();
            $table->boolean('headquarter_issued_license')->nullable();
            $table->binary('contract_credit_headquarter')->nullable();
            $table->boolean('province_issued_license')->nullable();
            $table->string('contract_credit');
            $table->string('contract_peymankar');
            $table->string('contract_moshaver_tarahi');
            $table->string('contract_moshaver_nezarat');
            $table->timestamps();
            $table->bigInteger('unique_id')->default(0);
            $table->string('created_at_fa')->nullable();
            $table->string('contract_mojavez_array', 255)->nullable();
            $table->string('contract_mojavez_data_meli_array', 255)->nullable();
            $table->string('contract_mojavez_data_setad_array', 255)->nullable();
            $table->string('contract_credit_national_array', 255)->nullable();
            $table->string('contract_tarh_array', 255)->nullable();
            $table->string('contract_mojavez_fa_array', 255)->nullable();
            $table->integer('status_rel')->nullable()->default(1);
            $table->string('credit_eblagh_meli')->nullable();
            $table->string('credit_takhsis_meli')->nullable();
            $table->unsignedInteger('user_id')->nullable()->index('user_foreign_key');
            $table->integer('is_new')->nullable()->default(0);
            $table->string('contract_number', 20)->nullable();
            $table->text('documents')->nullable();
        });
    }

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