id(); $table->foreignId('conversation_id')->constrained()->cascadeOnDelete(); $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete(); $table->string('type')->default('text')->index(); $table->text('body'); $table->json('metadata')->nullable(); $table->timestamp('edited_at')->nullable(); $table->timestamps(); $table->index(['conversation_id', 'created_at']); $table->index(['user_id', 'created_at']); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('messages'); } };