<?php

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

class CreateCompaniesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('companies', function (Blueprint $table) {
            $table->id();
            $table->string('name',100);
            $table->string('nit',15);
            $table->string('address',100);
            $table->string('state',2)->nullable();
            $table->string('city',5)->nullable();
            $table->string('phone',15);
            $table->string('email',100)->nullable();
            $table->string('legal_representative',100);
            $table->enum('document_type_representative', ['1', '2', '3','4'])->default('1');
            $table->string('document_representative',15)->nullable();
            $table->string('document_expedition_representative',50)->nullable();
            $table->string('image', 100)->nullable();
            $table->bigInteger('plan_id')->unsigned()->nullable();
            $table->string('watermark',100)->nullable();
            $table->enum('plan_payment_status',['0','1'])->default('0');
            $table->tinyInteger('company_employee_update_time')->default(1);
            $table->foreign('plan_id')->references('id')->on('plans')
                ->onDelete('set null')->onUpdate('set null');
            $table->foreign('state')->references('code')->on('states')
                ->onDelete('set null')->onUpdate('set null');
            $table->foreign('city')->references('code')->on('cities')
                ->onDelete('set null')->onUpdate('set null');
            $table->timestamps();
        });
    }

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