<?php

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

class CreateTransactionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('transactions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('from_account_id');
            $table->unsignedBigInteger('to_account_id');
            $table->unsignedBigInteger('creator_user_id')->nullable();
            $table->boolean('from_authorised_by_user_id')->default(false);
            $table->timestamp('from_authorisation_time')->nullable();
            $table->boolean('to_authorised_by_user_id')->default(false);
            $table->timestamp('to_authorisation_time')->nullable();
            $table->integer('amount');
            $table->dateTime('programmed_time')->nullable();
            $table->text('description');
            $table->string('from_reference')->nullable();;
            $table->string('to_reference')->nullable();;
            $table->unsignedBigInteger('transaction_type_id')->nullable();
            $table->unsignedBigInteger('transaction_status_id')->nullable();
            $table->unsignedBigInteger('cancelled_by_user_id')->nullable();
            $table->timestamp('cancelled_time')->nullable();
            $table->unsignedBigInteger('advertisement_id')->nullable();
            $table->timestamps();
        });
    }

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