<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('member_plans', function (Blueprint $table) {
            $table->id();
            $table->string('member_id')->index();
            $table->string('plan_id')->index();
            $table->string('status')->default('active');
            $table->dateTime('start')->nullable();
            $table->dateTime('end')->nullalbe();
            
            $table->timestamps();
            $table->softDeletes();
            
            $table->foreignId('created_by')->nullable();
            $table->foreignId('updated_by')->nullable();
            $table->foreignId('deleted_by')->nullable();

            $table->index(['member_id', 'plan_id']);
        });
    }

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