<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('tracking_modes', function (Blueprint $table) {
            $table->tinyIncrements('id');
            $table->string('code', 30)->unique();
            $table->string('name', 100);
            $table->unsignedTinyInteger('sort_order')->default(0);
        });

        DB::table('tracking_modes')->insert([
            ['id' => 1, 'code' => 'none',         'name' => 'None',              'sort_order' => 1],
            ['id' => 2, 'code' => 'serial',        'name' => 'Serial Number',     'sort_order' => 2],
            ['id' => 3, 'code' => 'batch',         'name' => 'Batch / Expiry',    'sort_order' => 3],
            ['id' => 4, 'code' => 'batch_serial',  'name' => 'Batch + Serial',    'sort_order' => 4],
        ]);
    }

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