<?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('rates', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('member_id')->nullable();
            $table->foreign('member_id')->nullable()->references('id')->on('members')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('member_course_id')->nullable();
            $table->foreign('member_course_id')->nullable()->references('id')->on('member_courses')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('course_subscription_id')->nullable();
            $table->foreign('course_subscription_id')->nullable()->references('id')->on('course_subscriptions')->onUpdate('cascade')->onDelete('cascade');
            $table->decimal('price', $precision = 8, $scale = 2);
            $table->datetime('date')->nullable();
            $table->string('months')->nullable();
            $table->string('note')->nullable();
            $table->integer('status')->default(0);
            $table->softDeletes();
            $table->timestamps();
        });
    }

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