<?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_articles', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('article_nature_id')->nullable()->index('article_nature_id');
            $table->string('product_type', 100)->nullable();
            $table->unsignedInteger('product_id')->nullable();
            $table->string('ref', 50)->nullable()->unique('ref');
            $table->string('name')->nullable();
            $table->string('slug')->nullable()->unique('slug');
            $table->unsignedInteger('hash')->nullable();
            $table->text('description')->nullable();
            $table->tinyInteger('visible')->nullable()->index('visible');
            $table->unsignedTinyInteger('homepage')->nullable()->index('homepage');
            $table->unsignedSmallInteger('created_by')->nullable();
            $table->unsignedSmallInteger('updated_by')->nullable();
            $table->unsignedSmallInteger('deleted_by')->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->index(['product_type', 'product_id'], 'product_type');
        });
    }

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