Files
analytics/database/migrations/2026_03_17_000005_create_events_table.php
T
2026-03-18 10:56:35 +02:00

36 lines
1.2 KiB
PHP

<?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('events', function (Blueprint $table) {
$table->id();
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
$table->foreignId('visitor_id')->constrained()->cascadeOnDelete();
$table->foreignId('analytics_session_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('category')->nullable();
$table->string('action')->nullable();
$table->string('label')->nullable();
$table->decimal('value', 15, 4)->nullable();
$table->json('properties')->nullable();
$table->timestamp('occurred_at');
$table->timestamps();
$table->index(['website_id', 'name', 'occurred_at']);
$table->index(['website_id', 'occurred_at']);
$table->index('category');
});
}
public function down(): void
{
Schema::dropIfExists('events');
}
};