<?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::dropIfExists('ad_campaign_reports');

        Schema::create('ad_campaign_reports', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ad_campaign_id')->constrained('ad_campaigns')->cascadeOnDelete();
            $table->decimal('spend', 10, 2)->default(0);
            $table->integer('reach')->default(0);
            $table->integer('impressions')->default(0);
            $table->integer('clicks')->default(0);
            $table->decimal('ctr', 5, 2)->default(0); // Click-Through Rate
            $table->decimal('cpc', 10, 2)->default(0); // Cost Per Click
            $table->decimal('cpm', 10, 2)->default(0); // Cost Per Mille
            $table->integer('results')->default(0);
            $table->decimal('cost_per_result', 10, 2)->default(0);
            $table->integer('messages')->default(0);
            $table->integer('leads')->default(0);
            $table->date('report_date');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('ad_campaign_reports');
    }
};
