<?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_orders', function (Blueprint $table) {
            $table->increments('id');
            $table->char('uuid', 36)->nullable()->index('uuid');
            $table->string('ref', 50)->nullable();
            $table->unsignedInteger('customer_id')->nullable()->index('customer_id');
            $table->unsignedInteger('delivery_address_id')->nullable();
            $table->unsignedSmallInteger('sale_channel_id')->nullable()->index('sale_channel_id');
            $table->unsignedSmallInteger('delivery_id')->nullable()->index('delivery_id');
            $table->string('delivery_ref', 50)->nullable();
            $table->tinyInteger('delivery_type_id')->nullable();
            $table->tinyText('delivery_link')->nullable();
            $table->unsignedTinyInteger('payment_type')->nullable();
            $table->unsignedTinyInteger('status')->nullable()->default(0);
            $table->unsignedTinyInteger('tax')->nullable()->default(0);
            $table->unsignedDecimal('total', 10)->nullable();
            $table->unsignedDecimal('taxes', 10)->nullable();
            $table->unsignedDecimal('total_taxed', 10)->nullable();
            $table->unsignedDecimal('shipping', 10)->nullable();
            $table->unsignedDecimal('total_shipped', 10)->nullable();
            $table->text('comment')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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