2026_02_28_170200_create_user_notifications_table.php 1020 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. public function up(): void
  8. {
  9. Schema::create('user_notifications', function (Blueprint $table) {
  10. $table->id();
  11. $table->foreignId('user_id')->constrained()->cascadeOnDelete();
  12. $table->string('type'); // platform | reclamation | schedule
  13. $table->string('event'); // created | status_changed | schedule_added
  14. $table->string('title');
  15. $table->text('message');
  16. $table->text('message_html')->nullable();
  17. $table->json('data')->nullable();
  18. $table->timestamp('read_at')->nullable();
  19. $table->timestamps();
  20. $table->index(['user_id', 'read_at']);
  21. $table->index(['type', 'event']);
  22. });
  23. }
  24. public function down(): void
  25. {
  26. Schema::dropIfExists('user_notifications');
  27. }
  28. };