22 lines
911 B
PHP
22 lines
911 B
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('reviews', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
|
$table->unsignedTinyInteger('rating')->nullable(); // 1-10
|
|
$table->text('body');
|
|
$table->boolean('has_spoilers')->default(false);
|
|
$table->unsignedInteger('helpful_count')->default(0);
|
|
$table->timestamps();
|
|
$table->unique(['user_id', 'game_id']);
|
|
$table->index(['game_id', 'helpful_count']);
|
|
});
|
|
}
|
|
public function down(): void { Schema::dropIfExists('reviews'); }
|
|
};
|