<?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
    {
        Schema::create('shop_product_prices', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('shop_product_id');
            $table->unsignedBigInteger('shop_id');
            $table->decimal('price', 15, 2)->default(0);
            $table->timestamps();

            $table->foreign('shop_product_id')->references('id')->on('shop_products')->onDelete('cascade');
            $table->foreign('shop_id')->references('id')->on('accounts')->onDelete('cascade');
            $table->unique(['shop_product_id', 'shop_id']);
            $table->index('shop_id');
        });
    }

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