2025_11_09_131811_create_messages_table.php 980 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use App\Enums\Status;
  3. use App\Models\Chat;
  4. use Illuminate\Database\Migrations\Migration;
  5. use Illuminate\Database\Schema\Blueprint;
  6. use Illuminate\Support\Facades\Schema;
  7. return new class extends Migration {
  8. /**
  9. * Run the migrations.
  10. */
  11. public function up(): void
  12. {
  13. Schema::create('messages', function (Blueprint $table) {
  14. $table->uuid('id')->primary();
  15. $table->foreignIdFor(Chat::class)->constrained()->cascadeOnUpdate()->cascadeOnDelete();
  16. $table->longText('thinking')->nullable();
  17. $table->longText('content')->nullable();
  18. $table->string('role')->default('human');
  19. $table->jsonb('fields')->nullable();
  20. $table->tinyInteger('status')->default(Status::Completed);
  21. $table->timestamps();
  22. });
  23. }
  24. /**
  25. * Reverse the migrations.
  26. */
  27. public function down(): void
  28. {
  29. Schema::dropIfExists('messages');
  30. }
  31. };