<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('prd_str', function (Blueprint $table) {
            $table->id();

            $table->foreignId('product_id')->constrained('prd_items')->onDelete('cascade');
            $table->foreignId('store_id')->constrained('str')->onDelete('cascade');

            // Optional extra data per store-product relation
            $table->integer('available')->nullable();
            $table->bigInteger('price')->nullable();
            $table->bigInteger('sold')->nullable();
            $table->longText('logs')->nullable();
            $table->json('reviews')->nullable();
            $table->string('status', 50)->nullable();
            $table->string('remarks', 150)->nullable();
            $table->longText('description')->nullable();

            $table->boolean('is_active')->default(true);

            $table->timestamps();

            $table->unique(['product_id', 'store_id']);
        });
    }

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