28 lines
945 B
PHP
28 lines
945 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class CreateCommentsTable extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('comments', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('disease_id')->constrained()->onDelete('cascade');
|
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
|
$table->text('content')->nullable(); // Allow null for deleted comments
|
|
$table->foreignId('parent_id')->nullable()->constrained('comments')->nullOnDelete();
|
|
$table->enum('status', ['active', 'deleted'])->default('active'); // Add status column
|
|
$table->softDeletes(); // Add soft deletes
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('comments');
|
|
}
|
|
}
|