Edit File: 2024_09_21_171051_create_comments_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('comments', function (Blueprint $table) { $table->id(); $table->string('description', 500); $table->boolean('is_urgent')->nullable()->default(false); $table->unsignedBigInteger('user_id'); $table->unsignedBigInteger('anime_id')->nullable(); $table->unsignedBigInteger('video_id')->nullable(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('anime_id')->references('id')->on('animes')->onDelete('cascade'); $table->foreign('video_id')->references('id')->on('videos')->onDelete('cascade'); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('comments'); } };
Back