39498-vm/database/migrations/2026_04_06_055038_create_events_table.php
2026-04-06 06:10:54 +00:00

29 lines
1.1 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->enum('event_type', ['request_created', 'recommendation_viewed', 'recommendation_clicked', 'booking_started', 'booking_completed']);
$table->foreignId('ride_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('offer_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('booking_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('ride_recommendation_id')->nullable()->constrained('ride_recommendations')->nullOnDelete();
$table->string('session_id')->nullable();
$table->json('meta')->nullable();
$table->timestamp('created_at')->useCurrent();
});
}
public function down(): void
{
Schema::dropIfExists('events');
}
};