<?php

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

return new class extends Migration {
    public function up(): void
    {
        Schema::create('org_str', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('organization_id');
            $table->unsignedBigInteger('store_id');
            $table->timestamps();

            $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade');
            $table->foreign('store_id')->references('id')->on('str')->onDelete('cascade');

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

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