Files
RomhackPlaza/database/migrations/2026_05_10_072747_create_entries_table.php
2026-06-16 16:21:43 +02:00

59 lines
2.0 KiB
PHP

<?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('entries', function (Blueprint $table) {
// Entry Management
$table->id();
$table->enum('type', [
'translations', 'romhacks', 'homebrew', 'utilities', 'documents', 'lua-scripts', 'tutorials'
]);
$table->string( 'title' );
$table->string( 'slug' )->unique();
$table->longText( 'description' );
$table->string( 'main_image' )->nullable();
$table->enum( 'state', [ 'draft', 'pending', 'published', 'locked', 'hidden' ] )->default('draft');
$table->boolean('featured')->default(false);
// FK
$table->foreignId('game_id')->nullable()->constrained('games')->nullOnDelete();
$table->foreignId('platform_id')->nullable()->constrained('platforms')->nullOnDelete(); // Only for utilities/documents/tutorials.
$table->foreignId('status_id')->nullable()->constrained('status')->nullOnDelete();
// Fields
$table->string('version', 50)->nullable();
$table->date( 'release_date' )->nullable();
$table->text( 'staff_credits' )->nullable();
$table->string( 'relevant_link', 500 )->nullable();
$table->string( 'youtube_link', 500 )->nullable();
// Author
$table->unsignedBigInteger( 'user_id' ); // xf_user_id
$table->unsignedBigInteger( 'comments_thread_id' )->nullable(); // xf_thread
$table->timestamps();
$table->index(['type','status','game_id','platform_id','status_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('entries');
}
};