<?php

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

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

            $table->unsignedInteger('shopping_order_id');

            $table->string('clearingtype',3);
            $table->string('wallettype', 3)->nullable();
            $table->string('onlinebanktransfertype',3)->nullable();

            $table->string('reference', 16);
            $table->unsignedInteger('amount');
            $table->string('currency', 6);

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

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

            $table->timestamps();

            $table->foreign('shopping_order_id')
                   ->references('id')
                   ->on('shopping_orders');

        });
    }

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