move into sonardesk

This commit is contained in:
Mark Gregory
2026-10-12 14:50:13 +01:00
parent 5f0d2ceb72
commit 38b4a7406f
879 changed files with 24021 additions and 1 deletions
@@ -0,0 +1,80 @@
<?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('analytics_events', function (Blueprint $table) {
$table->id();
$table->uuid('event_id')->unique();
$table->foreignId('site_id')->nullable()->constrained('sites')->nullOnDelete();
$table->string('event_type', 40)->index();
$table->string('path', 2048)->nullable();
$table->string('title')->nullable();
$table->string('referrer', 2048)->nullable();
$table->string('visitor_hash', 64)->nullable()->index();
$table->string('session_hash', 64)->nullable()->index();
$table->string('ip_hash', 64)->nullable();
$table->string('country_code', 2)->nullable()->index();
$table->string('device_type', 20)->nullable()->index();
$table->string('browser', 40)->nullable();
$table->string('operating_system', 40)->nullable();
$table->nullableMorphs('subject');
$table->json('properties')->nullable();
$table->timestamp('occurred_at')->index();
$table->timestamps();
$table->index(['site_id', 'event_type', 'occurred_at']);
});
Schema::create('analytics_daily_metrics', function (Blueprint $table) {
$table->id();
$table->foreignId('site_id')->nullable()->constrained('sites')->nullOnDelete();
$table->date('metric_date')->index();
$table->string('metric', 60);
$table->string('dimension', 120)->default('all');
$table->unsignedBigInteger('value')->default(0);
$table->json('metadata')->nullable();
$table->timestamps();
$table->unique(['site_id', 'metric_date', 'metric', 'dimension'], 'analytics_daily_unique');
});
Schema::create('analytics_reports', function (Blueprint $table) {
$table->id();
$table->foreignId('site_id')->nullable()->constrained('sites')->nullOnDelete();
$table->string('name');
$table->string('report_type', 40)->default('overview');
$table->json('filters')->nullable();
$table->json('columns')->nullable();
$table->string('schedule')->nullable();
$table->string('format', 10)->default('csv');
$table->json('recipients')->nullable();
$table->boolean('is_active')->default(true)->index();
$table->timestamp('last_run_at')->nullable();
$table->timestamp('next_run_at')->nullable()->index();
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
});
Schema::create('analytics_report_runs', function (Blueprint $table) {
$table->id();
$table->foreignId('analytics_report_id')->constrained('analytics_reports')->cascadeOnDelete();
$table->string('status', 20)->default('pending')->index();
$table->string('disk')->nullable();
$table->string('path')->nullable();
$table->unsignedBigInteger('row_count')->default(0);
$table->text('error')->nullable();
$table->timestamp('started_at')->nullable();
$table->timestamp('completed_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('analytics_report_runs');
Schema::dropIfExists('analytics_reports');
Schema::dropIfExists('analytics_daily_metrics');
Schema::dropIfExists('analytics_events');
}
};