<?php

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

class CreatePostalExchangesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('postal_exchanges')) {
            Schema::create('postal_exchanges', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->timestamps();

                $table->unsignedInteger('created_by');
                $table->unsignedInteger('last_updated_by')->nullable();

                $table->string('type');
                $table->dateTime('date');
                $table->string('ref_no', 25)->unique();
                $table->string('subject')->nullable();

                $table->string('to');

                $table->string('from');

                $table->text('note')->nullable();

                $table->text('attachment')->nullable();

                $table->boolean('status')->default(1);
            });

        }
    }

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