Implement tenant announcements and audit log fixes
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-02 14:19:46 +01:00
parent 412ecbe691
commit 8f13465415
33 changed files with 1400 additions and 117 deletions

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenant_announcements', function (Blueprint $table) {
$table->id();
$table->string('title', 160);
$table->text('body');
$table->string('cta_label', 160)->nullable();
$table->string('cta_url', 255)->nullable();
$table->string('status', 24)->default('draft');
$table->string('audience', 24)->default('all');
$table->json('segments')->nullable();
$table->boolean('email_enabled')->default(true);
$table->timestamp('starts_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->foreignIdFor(\App\Models\User::class, 'created_by')->nullable()->constrained('users')->nullOnDelete();
$table->foreignIdFor(\App\Models\User::class, 'updated_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->index(['status', 'starts_at']);
$table->index(['audience', 'status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenant_announcements');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenant_announcement_deliveries', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_announcement_id')->constrained('tenant_announcements')->cascadeOnDelete();
$table->foreignId('tenant_id')->constrained('tenants')->cascadeOnDelete();
$table->string('channel', 24)->default('mail');
$table->string('status', 24)->default('queued');
$table->timestamp('sent_at')->nullable();
$table->timestamp('failed_at')->nullable();
$table->string('failure_reason', 255)->nullable();
$table->timestamps();
$table->unique(['tenant_announcement_id', 'tenant_id', 'channel'], 'tenant_announcement_delivery_unique');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenant_announcement_deliveries');
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenant_announcement_targets', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_announcement_id')->constrained('tenant_announcements')->cascadeOnDelete();
$table->foreignId('tenant_id')->constrained('tenants')->cascadeOnDelete();
$table->timestamps();
$table->unique(['tenant_announcement_id', 'tenant_id'], 'tenant_announcement_target_unique');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenant_announcement_targets');
}
};