<?php

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

class CreateUserCreditsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_credits', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('auth_user_id');
            $table->string('credit_number', 255)->nullable();
            $table->decimal('net', 13, 2)->nullable();
            $table->decimal('tax_rate', 8, 2)->nullable();
            $table->decimal('tax', 8, 2)->nullable();
            $table->decimal('total', 13, 2)->nullable();
            $table->date('date')->nullable();
            $table->text('credit')->nullable();
            $table->text('user_margins')->nullable();
            $table->text('user_credits')->nullable();

            $table->boolean('paid_out')->default(false);
            $table->boolean('cancellation')->default(false);
            $table->unsignedTinyInteger('status')->index()->default(0);

            $table->timestamps();

            $table->foreign('auth_user_id')
            ->references('id')
            ->on('users');
        });
    }

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