File: /var/www/console.fixgini.com/database/migrations/2024_09_09_130111_create_messages_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('messages', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('sender_id');
$table->unsignedBigInteger('recipient_id');
$table->text('message');
$table->string('conversation_id');
$table->string('file_url')->nullable();
$table->string('file_public_id')->nullable();
// Foreign keys
$table->foreign('sender_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('recipient_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('messages');
}
};