Implement compliance exports and retention overrides
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 20:13:45 +01:00
parent 5fd546c428
commit eed7699549
45 changed files with 2319 additions and 40 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use App\Enums\RetentionOverrideScope;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\RetentionOverride>
*/
class RetentionOverrideFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'scope' => RetentionOverrideScope::TENANT,
'tenant_id' => Tenant::factory(),
'event_id' => null,
'reason' => $this->faker->sentence(3),
'note' => $this->faker->optional()->sentence(),
'created_by_id' => User::factory(),
'released_by_id' => null,
'released_at' => null,
];
}
}

View File

@@ -0,0 +1,39 @@
<?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('retention_overrides', function (Blueprint $table) {
$table->id();
$table->string('scope', 20);
$table->foreignId('tenant_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('event_id')->nullable()->constrained()->nullOnDelete();
$table->string('reason', 200);
$table->text('note')->nullable();
$table->foreignId('created_by_id')->nullable()->constrained('users')->nullOnDelete();
$table->foreignId('released_by_id')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('released_at')->nullable();
$table->timestamps();
$table->index(['scope', 'released_at']);
$table->index(['tenant_id', 'released_at']);
$table->index(['event_id', 'released_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('retention_overrides');
}
};

View File

@@ -0,0 +1,35 @@
<?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::table('data_exports', function (Blueprint $table) {
$table->string('scope', 20)->default('user')->after('tenant_id');
$table->foreignId('event_id')->nullable()->after('scope')->constrained()->nullOnDelete();
$table->boolean('include_media')->default(false)->after('event_id');
$table->index(['scope']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('data_exports', function (Blueprint $table) {
$table->dropIndex(['scope']);
$table->dropColumn('include_media');
$table->dropConstrainedForeignId('event_id');
$table->dropColumn('scope');
});
}
};