<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('crews', function (Blueprint $table) {
            $table->id();

            $table->string('name');
            $table->text('description')->nullable();

            // invite code
            $table->string('slug')->unique();

            // avatar image
            $table->foreignId('image_id')
                ->nullable()
                ->constrained('images')
                ->nullOnDelete();

            // optional cover image
            $table->foreignId('cover_image_id')
                ->nullable()
                ->constrained('images')
                ->nullOnDelete();

            $table->string('avatar_icon')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('crews');
    }
};
