<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Hapus tabel subcategories jika ada
        Schema::dropIfExists('subcategories');
        
        // Modifikasi tabel categories
        Schema::table('categories', function (Blueprint $table) {
            // Tambahkan kolom untuk subkategori
            $table->string('subcategory1')->nullable();
            $table->string('subcategory2')->nullable();
            $table->string('subcategory3')->nullable();
            $table->string('subcategory4')->nullable();
            $table->string('subcategory5')->nullable();
            
            // Tambahkan kolom untuk nilai subkategori
            $table->integer('value1')->default(1);
            $table->integer('value2')->default(2);
            $table->integer('value3')->default(3);
            $table->integer('value4')->default(4);
            $table->integer('value5')->default(5);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('categories', function (Blueprint $table) {
            // Hapus kolom subkategori
            $table->dropColumn([
                'subcategory1', 'subcategory2', 'subcategory3', 'subcategory4', 'subcategory5',
                'value1', 'value2', 'value3', 'value4', 'value5'
            ]);
        });
        
        // Buat ulang tabel subcategories
        Schema::create('subcategories', function (Blueprint $table) {
            $table->id();
            $table->foreignId('category_id')->constrained()->onDelete('cascade');
            $table->string('name');
            $table->timestamps();
        });
    }
}; 