<?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()
    // {
    //     Schema::create('jewelry_images', function (Blueprint $table) {
    //         $table->id();
    //         $table->foreignId('jewelry_id')
    //         ->constrained('jewelry') // 👈 yaha fix
    //         ->onDelete('cascade');
    //         $table->string('image_path');
    //         $table->integer('sort_order')->default(0);
    //         $table->timestamps();
    //     });
    // }

    public function up(): void
{
    if (!Schema::hasTable('jewelry_images')) {

        Schema::create('jewelry_images', function (Blueprint $table) {

            $table->id();
            $table->unsignedBigInteger('jewelry_id');
            $table->string('image_path');
            $table->integer('sort_order')->default(0);
            $table->timestamps();
        });

    }
}

    public function down()
    {
        Schema::dropIfExists('jewelry_images');
    }
};
