id(); $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete(); $table->string('visitor_token')->unique(); $table->string('status')->default('open'); $table->timestamp('last_message_at')->nullable()->index(); $table->timestamps(); }); Schema::create('chat_messages', function (Blueprint $table) { $table->id(); $table->foreignId('chat_conversation_id')->constrained('chat_conversations')->cascadeOnDelete(); $table->string('sender', 20); $table->text('body'); $table->boolean('is_read')->default(false); $table->timestamps(); $table->index(['chat_conversation_id', 'created_at']); $table->index(['chat_conversation_id', 'sender', 'is_read']); }); } public function down(): void { Schema::dropIfExists('chat_messages'); Schema::dropIfExists('chat_conversations'); } };