Files
healthcareapi/database/migrations/2024_11_20_133119_create_comments_table.php
2026-06-08 19:58:50 +07:00

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');
}
}