<?php

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

/**
 * Creates the site_menu table for fresh installs.
 *
 * Existing installations already have this table (created by the platform
 * install migration), so this is guarded by hasTable() and is a no-op there.
 * The column set mirrors the existing table exactly.
 */
return new class extends Migration
{
    public function up(): void
    {
        if (Schema::hasTable('site_menu')) {
            return;
        }

        Schema::create('site_menu', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->index();
            $table->integer('parent_id')->index();
            $table->integer('published')->default(1)->index();
            $table->string('target')->default('_self');
            $table->string('url');
            $table->integer('order');
            $table->string('css_class');
            $table->integer('category_list');
            $table->integer('category_id');
            $table->integer('brand_list');
            $table->integer('site_tree');
            $table->timestamps();
            $table->integer('single_category');
            $table->tinyInteger('single_cms_page');
            $table->dateTime('deleted_at')->nullable()->index();
        });
    }

    public function down(): void
    {
        // Intentionally left as a no-op: this table predates the module and is
        // shared platform data. We never want a module rollback to drop it.
    }
};
