gamtest / database /migrations /2025_07_26_194151_create_analytics_snapshots_table.php
veela4's picture
Upload folder using huggingface_hub
70ba896 verified
<?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('analytics_snapshots', function (Blueprint $table) {
$table->id();
$table->date('date');
$table->integer('hour')->nullable(); // 0-23 for hourly data, null for daily aggregates
$table->decimal('revenue', 10, 2)->default(0);
$table->decimal('profit', 10, 2)->default(0);
$table->integer('orders_count')->default(0);
$table->integer('customers_count')->default(0);
$table->decimal('avg_order_value', 8, 2)->default(0);
$table->decimal('conversion_rate', 5, 4)->default(0); // 0.0000 to 1.0000
$table->timestamps();
// Indexes for performance
$table->index(['date', 'hour']);
$table->index('date');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('analytics_snapshots');
}
};