<?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('order_numbers', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->integer('id');
            $table->unsignedTinyInteger('year');
            $table->unsignedInteger('supplier_id');
            $table->unsignedInteger('order_id')->nullable();
            $table->timestamps();
            $table->primary(['supplier_id', 'year', 'id']);
            $table->unique('order_id');
        });
        Schema::table('order_numbers', function ($table) {
            $table->increments('id')->unsigned()->change();
        });

    }

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