<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_invoices', function (Blueprint $table) {
            $table->mediumIncrements('id');
            $table->char('uuid', 36)->nullable()->index('uuid');
            $table->string('ref', 50)->nullable();
            $table->unsignedInteger('customer_id')->nullable()->index('customer_id');
            $table->unsignedInteger('invoice_address_id')->nullable();
            $table->unsignedMediumInteger('order_id')->nullable()->index('order_id');
            $table->unsignedTinyInteger('payment_type')->nullable();
            $table->unsignedTinyInteger('status')->nullable()->default(0)->index('status');
            $table->decimal('total', 10);
            $table->decimal('taxes', 10);
            $table->decimal('total_taxed', 10);
            $table->decimal('shipping', 10);
            $table->decimal('total_shipped', 10);
            $table->date('date_invoice')->nullable();
            $table->date('date_due')->nullable();
            $table->text('comment')->nullable();
            $table->unsignedSmallInteger('created_by')->nullable();
            $table->unsignedSmallInteger('updated_by')->nullable();
            $table->unsignedSmallInteger('deleted_by')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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