2025_11_09_131811_create_messages_table.php 925 B

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