EscolaLMS/Consultations

View on GitHub
database/migrations/2022_02_02_135907_create_consultations_participants_table.php

Summary

Maintainability
A
3 hrs
Test Coverage
<?php

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

class CreateConsultationsParticipantsTable extends Migration
{

    public function up(): void
    {
        Schema::create('consultations_participants', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('consultation_id')->unsigned()->index();
            $table->bigInteger('user_id')->unsigned()->nullable();
            $table->string('status')->default(null)->nullable();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL');
            $table->foreign('consultation_id')->references('id')->on('consultations')->onDelete('CASCADE');
        });
    }

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