festbench-web/database/migrations/2026_09_18_000003_create_session_summaries.php

61 lines
2.6 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Precomputed session-grouped summary for the home page.
*
* A session = runs sharing label + model + quant + gpu + gpu_count +
* user. Bands render as session_summaries rows; the per-suite aggregate
* lines under each band render as session_suite_rows. Rebuilt wholesale
* by festbench:summary (scheduled + after import) — the request path
* only reads, never aggregates.
*/
public function up(): void
{
Schema::create('session_summaries', function (Blueprint $table) {
$table->id();
$table->string('session_key', 255)->unique();
$table->string('label', 255)->nullable();
$table->string('model_id', 255)->nullable();
$table->string('model_quant', 64)->nullable();
$table->string('gpu', 128)->nullable();
$table->unsignedInteger('gpu_count')->nullable();
$table->string('runner_name', 255)->nullable();
$table->foreignId('user_id')->nullable();
$table->string('visibility', 16)->default('public');
$table->timestamp('ran_at')->nullable();
$table->unsignedInteger('total_passed')->default(0);
$table->unsignedInteger('total_failed')->default(0);
$table->unsignedInteger('total_tokens')->default(0);
$table->unsignedInteger('sequence')->index()->comment('band order, newest first');
$table->timestamps();
});
Schema::create('session_suite_rows', function (Blueprint $table) {
$table->id();
$table->foreignId('session_summary_id')->constrained('session_summaries')->cascadeOnDelete();
$table->foreignId('benchmark_run_id')->constrained()->cascadeOnDelete();
$table->string('run_id', 32);
$table->string('suite', 32);
$table->string('level', 16)->nullable();
$table->unsignedInteger('passed')->default(0);
$table->unsignedInteger('failed')->default(0);
$table->double('avg_user_tps')->nullable();
$table->double('weighted_user_tps')->nullable();
$table->unsignedInteger('total_tokens')->default(0);
$table->unsignedInteger('sequence')->comment('suite order within band');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('session_suite_rows');
Schema::dropIfExists('session_summaries');
}
};