fixed notification system and added a new tenant notifications receipt table to track read status and filter messages by scope.

This commit is contained in:
Codex Agent
2025-12-17 10:57:19 +01:00
parent 0aae494945
commit d64839ba2f
31 changed files with 1089 additions and 127 deletions

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('tenant_notification_receipts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id');
$table->unsignedBigInteger('notification_log_id');
$table->unsignedBigInteger('user_id')->nullable();
$table->string('recipient')->nullable();
$table->enum('status', ['delivered', 'read', 'dismissed'])->default('delivered');
$table->timestamps();
$table->index(['tenant_id', 'notification_log_id']);
$table->index(['tenant_id', 'user_id']);
$table->index(['tenant_id', 'status']);
$table->foreign('tenant_id')->references('id')->on('tenants')->cascadeOnDelete();
$table->foreign('notification_log_id')->references('id')->on('tenant_notification_logs')->cascadeOnDelete();
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('tenant_notification_receipts');
}
};