2025_11_09_131811_create_messages_table.php 760 B

123456789101112131415161718192021222324252627282930313233
  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->timestamps();
  18. });
  19. }
  20. /**
  21. * Reverse the migrations.
  22. */
  23. public function down(): void
  24. {
  25. Schema::dropIfExists('messages');
  26. }
  27. };