<?php

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

class CreatePaymentTypesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payment_types', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name',100);
            $table->string('slug',100)->unique()->index();
            $table->string('description',100);
            $table->boolean('active')->index();
            $table->boolean('auto')->index();
            $table->timestamps();
        });

        Schema::table('payments',function (Blueprint $table){
            $table->foreign("payment_type_id")->references("id")->on("payment_types")->onDelete("set null"); //si un box es borra, aquest es queda sense idBox
        });
    }

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