uuid('session_id')->primary(); $table->string('session_name', 255)->nullable(); $table->string('status', 16)->default('OPEN'); $table->unsignedBigInteger('last_seq')->default(0); $table->timestamps(); }); Schema::create('messages', function (Blueprint $table) { $table->uuid('message_id')->primary(); $table->uuid('session_id'); $table->string('role', 32); $table->string('type', 64); $table->text('content')->nullable(); $table->jsonb('payload')->nullable(); $table->timestamp('created_at')->useCurrent(); $table->unsignedBigInteger('seq'); $table->uuid('reply_to')->nullable(); $table->string('dedupe_key', 128)->nullable(); $table->foreign('session_id')->references('session_id')->on('chat_sessions')->onDelete('cascade'); $table->unique(['session_id', 'seq']); $table->unique(['session_id', 'dedupe_key']); $table->index(['session_id', 'seq']); }); } public function down(): void { Schema::dropIfExists('messages'); Schema::dropIfExists('chat_sessions'); } };