<?php

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

class CreatePaymentTransactionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payment_transactions', function (Blueprint $table) {
            $table->increments('id');

            $table->unsignedInteger('shopping_payment_id');

            $table->string('request',20);
            $table->unsignedInteger('txid');
            $table->unsignedInteger('userid');

            $table->string('status',20)->nullable();

            $table->string('key',40)->nullable();
            $table->string('txaction',20)->nullable();

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

            $table->unsignedInteger('errorcode')->nullable();
            $table->string('errormessage')->nullable();
            $table->string('customermessage')->nullable();

            $table->char('mode', 4)->nullable();

            $table->timestamps();

            $table->foreign('shopping_payment_id')
                ->references('id')
                ->on('shopping_payments');

        });
    }

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