<?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('missions', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users');
            $table->string('username');
            $table->foreignId('state_id')->constrained('mission_states')->noActionOnDelete();
            $table->string('state_name');
            $table->unsignedTinyInteger('province_id')->nullable();
            $table->foreign('province_id')->references('id')->on('provinces')->noActionOnDelete();
            $table->string('province_name');
            $table->unsignedBigInteger('edare_shahri_id')->nullable();
            $table->foreign('edare_shahri_id')->references('id')->on('edarate_shahri')->noActionOnDelete();
            $table->string('edare_shahri_name')->nullable();
            $table->json('requested_machines');
            $table->string('type');
            $table->dateTime('start_date');
            $table->dateTime('end_date');
            $table->dateTime('request_date');
            $table->text('description')->nullable();
            $table->string('end_point');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('missions');
    }
};
