migrant-web/database/migrations/2026_05_18_104419_create_messages_table.php
2026-05-20 13:26:43 +05:30

33 lines
878 B
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('messages', function (Blueprint $table) {
$table->id();
$table->foreignId('conversation_id')->constrained('conversations')->onDelete('cascade');
$table->string('sender_type'); // employer, worker
$table->unsignedBigInteger('sender_id'); // links to users (employer) or workers
$table->text('text');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('messages');
}
};