<?php

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

class CreatePaymentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payments', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->unsignedBigInteger('users_id');
            $table->string('especiality_id', 5);
            $table->string('payment_methods_id');
            $table->string('currencies_id');
            $table->decimal('amount', 10, 2);
            $table->string('reference');
            $table->string('description');
            $table->string('payer');
            $table->string('address_payer');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->nullable();
            
            $table->foreign('especiality_id', 'FK_6648f5d3668171aacb962f78654')->references('id')->on('especiality');
            $table->foreign('users_id', 'FK_d9245cc77eeed3f0ecfd9140271')->references('id')->on('users');
            $table->foreign('currencies_id', 'FK_f1eee91f662543c17d57d1b4b5a')->references('id')->on('currencies');
            $table->foreign('payment_methods_id', 'FK_fea3e4f18b962b446093c03187e')->references('id')->on('payment_methods');
        });
    }

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