<?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::table('courses', function (Blueprint $table) {
            $table->unsignedBigInteger('course_type_id')->nullable();
            $table->foreign('course_type_id')->nullable()->references('id')->on('course_types')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('causal_id')->nullable();
            $table->foreign('causal_id')->nullable()->references('id')->on('causals')->onUpdate('cascade')->onDelete('cascade');
            $table->integer('max_members');
            $table->string('instructor')->nullable();
            $table->decimal('price', $precision = 8, $scale = 2);
            $table->string('months')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('courses', function (Blueprint $table) {
            $table->dropColumn('course_type_id');
            $table->dropColumn('causal_id');
            $table->dropColumn('max_members');
            $table->dropColumn('instructor');
            $table->dropColumn('price');
            $table->dropColumn('months');
        });
    }
};
