<?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::table('receivings', function (Blueprint $table) {
            $table->string('document_no')->nullable()->unique()->after('id');
        });

        Schema::table('move_orders', function (Blueprint $table) {
            $table->string('document_no')->nullable()->unique()->after('id');
        });

        Schema::table('feed_consumptions', function (Blueprint $table) {
            $table->string('document_no')->nullable()->unique()->after('id');
        });

        Schema::table('misc_receipts', function (Blueprint $table) {
            $table->string('document_no')->nullable()->unique()->after('id');
        });

        Schema::table('misc_issues', function (Blueprint $table) {
            $table->string('document_no')->nullable()->unique()->after('id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('receivings', function (Blueprint $table) {
            $table->dropUnique(['document_no']);
            $table->dropColumn('document_no');
        });

        Schema::table('move_orders', function (Blueprint $table) {
            $table->dropUnique(['document_no']);
            $table->dropColumn('document_no');
        });

        Schema::table('feed_consumptions', function (Blueprint $table) {
            $table->dropUnique(['document_no']);
            $table->dropColumn('document_no');
        });

        Schema::table('misc_receipts', function (Blueprint $table) {
            $table->dropUnique(['document_no']);
            $table->dropColumn('document_no');
        });

        Schema::table('misc_issues', function (Blueprint $table) {
            $table->dropUnique(['document_no']);
            $table->dropColumn('document_no');
        });
    }
};
